68
68
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
69
69
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
70
70
71
- """basic checker for Python code"""
71
+ """Basic checker for Python code"""
72
72
import collections
73
73
import itertools
74
74
import re
@@ -266,7 +266,7 @@ def in_loop(node: nodes.NodeNG) -> bool:
266
266
267
267
268
268
def in_nested_list (nested_list , obj ):
269
- """return true if the object is an element of <nested_list> or of a nested
269
+ """Return true if the object is an element of <nested_list> or of a nested
270
270
list
271
271
"""
272
272
for elmt in nested_list :
@@ -401,7 +401,7 @@ def report_by_type_stats(
401
401
stats : LinterStats ,
402
402
old_stats : Optional [LinterStats ],
403
403
):
404
- """make a report of
404
+ """Make a report of
405
405
406
406
* percentage of different types documented
407
407
* percentage of different types with a bad name
@@ -438,7 +438,7 @@ def report_by_type_stats(
438
438
439
439
440
440
def redefined_by_decorator (node ):
441
- """return True if the object is a method redefined via decorator.
441
+ """Return True if the object is a method redefined via decorator.
442
442
443
443
For example:
444
444
@property
@@ -843,7 +843,7 @@ def _check_else_on_loop(self, node):
843
843
)
844
844
845
845
def _check_in_loop (self , node , node_name ):
846
- """check that a node is inside a for or while loop"""
846
+ """Check that a node is inside a for or while loop"""
847
847
for parent in node .node_ancestors ():
848
848
if isinstance (parent , (nodes .For , nodes .While )):
849
849
if node not in parent .orelse :
@@ -861,7 +861,7 @@ def _check_in_loop(self, node, node_name):
861
861
self .add_message ("not-in-loop" , node = node , args = node_name )
862
862
863
863
def _check_redefinition (self , redeftype , node ):
864
- """check for redefinition of a function / method / class name"""
864
+ """Check for redefinition of a function / method / class name"""
865
865
parent_frame = node .parent .frame ()
866
866
867
867
# Ignore function stubs created for type information
@@ -938,7 +938,7 @@ def _check_redefinition(self, redeftype, node):
938
938
939
939
940
940
class BasicChecker (_BasicChecker ):
941
- """checks for :
941
+ """Checks for :
942
942
* doc strings
943
943
* number of arguments, local variables, branches, returns and statements in
944
944
functions, methods
@@ -1088,7 +1088,7 @@ def __init__(self, linter):
1088
1088
self ._tryfinallys = None
1089
1089
1090
1090
def open (self ):
1091
- """initialize visit variables and statistics"""
1091
+ """Initialize visit variables and statistics"""
1092
1092
py_version = get_global_option (self , "py-version" )
1093
1093
self ._py38_plus = py_version >= (3 , 8 )
1094
1094
self ._tryfinallys = []
@@ -1162,11 +1162,11 @@ def _check_using_constant_test(self, node, test):
1162
1162
self .add_message ("using-constant-test" , node = node )
1163
1163
1164
1164
def visit_module (self , _ : nodes .Module ) -> None :
1165
- """check module name, docstring and required arguments"""
1165
+ """Check module name, docstring and required arguments"""
1166
1166
self .linter .stats .node_count ["module" ] += 1
1167
1167
1168
1168
def visit_classdef (self , _ : nodes .ClassDef ) -> None :
1169
- """check module name, docstring and redefinition
1169
+ """Check module name, docstring and redefinition
1170
1170
increment branch counter
1171
1171
"""
1172
1172
self .linter .stats .node_count ["klass" ] += 1
@@ -1305,7 +1305,7 @@ def visit_lambda(self, node: nodes.Lambda) -> None:
1305
1305
1306
1306
@utils .check_messages ("dangerous-default-value" )
1307
1307
def visit_functiondef (self , node : nodes .FunctionDef ) -> None :
1308
- """check function name, docstring, arguments, redefinition,
1308
+ """Check function name, docstring, arguments, redefinition,
1309
1309
variable names, max locals
1310
1310
"""
1311
1311
if node .is_method ():
@@ -1369,7 +1369,7 @@ def visit_return(self, node: nodes.Return) -> None:
1369
1369
1370
1370
@utils .check_messages ("unreachable" )
1371
1371
def visit_continue (self , node : nodes .Continue ) -> None :
1372
- """check is the node has a right sibling (if so, that's some unreachable
1372
+ """Check is the node has a right sibling (if so, that's some unreachable
1373
1373
code)
1374
1374
"""
1375
1375
self ._check_unreachable (node )
@@ -1388,7 +1388,7 @@ def visit_break(self, node: nodes.Break) -> None:
1388
1388
1389
1389
@utils .check_messages ("unreachable" )
1390
1390
def visit_raise (self , node : nodes .Raise ) -> None :
1391
- """check if the node has a right sibling (if so, that's some unreachable
1391
+ """Check if the node has a right sibling (if so, that's some unreachable
1392
1392
code)
1393
1393
"""
1394
1394
self ._check_unreachable (node )
@@ -1418,7 +1418,7 @@ def _check_misplaced_format_function(self, call_node):
1418
1418
"eval-used" , "exec-used" , "bad-reversed-sequence" , "misplaced-format-function"
1419
1419
)
1420
1420
def visit_call (self , node : nodes .Call ) -> None :
1421
- """visit a Call node -> check if this is not a disallowed builtin
1421
+ """Visit a Call node -> check if this is not a disallowed builtin
1422
1422
call and check for * or ** use
1423
1423
"""
1424
1424
self ._check_misplaced_format_function (node )
@@ -1436,7 +1436,7 @@ def visit_call(self, node: nodes.Call) -> None:
1436
1436
1437
1437
@utils .check_messages ("assert-on-tuple" , "assert-on-string-literal" )
1438
1438
def visit_assert (self , node : nodes .Assert ) -> None :
1439
- """check whether assert is used on a tuple or string literal."""
1439
+ """Check whether assert is used on a tuple or string literal."""
1440
1440
if (
1441
1441
node .fail is None
1442
1442
and isinstance (node .test , nodes .Tuple )
@@ -1453,7 +1453,7 @@ def visit_assert(self, node: nodes.Assert) -> None:
1453
1453
1454
1454
@utils .check_messages ("duplicate-key" )
1455
1455
def visit_dict (self , node : nodes .Dict ) -> None :
1456
- """check duplicate key in dictionary"""
1456
+ """Check duplicate key in dictionary"""
1457
1457
keys = set ()
1458
1458
for k , _ in node .items :
1459
1459
if isinstance (k , nodes .Const ):
@@ -1467,15 +1467,15 @@ def visit_dict(self, node: nodes.Dict) -> None:
1467
1467
keys .add (key )
1468
1468
1469
1469
def visit_tryfinally (self , node : nodes .TryFinally ) -> None :
1470
- """update try...finally flag"""
1470
+ """Update try...finally flag"""
1471
1471
self ._tryfinallys .append (node )
1472
1472
1473
1473
def leave_tryfinally (self , _ : nodes .TryFinally ) -> None :
1474
- """update try...finally flag"""
1474
+ """Update try...finally flag"""
1475
1475
self ._tryfinallys .pop ()
1476
1476
1477
1477
def _check_unreachable (self , node ):
1478
- """check unreachable code"""
1478
+ """Check unreachable code"""
1479
1479
unreach_stmt = node .next_sibling ()
1480
1480
if unreach_stmt is not None :
1481
1481
if (
@@ -1491,7 +1491,7 @@ def _check_unreachable(self, node):
1491
1491
self .add_message ("unreachable" , node = unreach_stmt )
1492
1492
1493
1493
def _check_not_in_finally (self , node , node_name , breaker_classes = ()):
1494
- """check that a node is not inside a 'finally' clause of a
1494
+ """Check that a node is not inside a 'finally' clause of a
1495
1495
'try...finally' statement.
1496
1496
If we find a parent which type is in breaker_classes before
1497
1497
a 'try...finally' block we skip the whole check.
@@ -1510,7 +1510,7 @@ def _check_not_in_finally(self, node, node_name, breaker_classes=()):
1510
1510
_parent = _node .parent
1511
1511
1512
1512
def _check_reversed (self , node ):
1513
- """check that the argument to `reversed` is a sequence"""
1513
+ """Check that the argument to `reversed` is a sequence"""
1514
1514
try :
1515
1515
argument = utils .safe_infer (utils .get_argument_from_call (node , position = 0 ))
1516
1516
except utils .NoSuchArgumentError :
@@ -1967,7 +1967,7 @@ def visit_global(self, node: nodes.Global) -> None:
1967
1967
"disallowed-name" , "invalid-name" , "assign-to-new-keyword" , "non-ascii-name"
1968
1968
)
1969
1969
def visit_assignname (self , node : nodes .AssignName ) -> None :
1970
- """check module level assigned names"""
1970
+ """Check module level assigned names"""
1971
1971
self ._check_assign_to_new_keyword_violation (node .name , node )
1972
1972
frame = node .frame ()
1973
1973
assign_type = node .assign_type ()
@@ -2006,7 +2006,7 @@ def visit_assignname(self, node: nodes.AssignName) -> None:
2006
2006
self ._check_name ("class_attribute" , node .name , node )
2007
2007
2008
2008
def _recursive_check_names (self , args ):
2009
- """check names in a possibly recursive list <arg>"""
2009
+ """Check names in a possibly recursive list <arg>"""
2010
2010
for arg in args :
2011
2011
if isinstance (arg , nodes .AssignName ):
2012
2012
self ._check_name ("argument" , arg .name , arg )
@@ -2054,7 +2054,7 @@ def _name_disallowed_by_regex(self, name: str) -> bool:
2054
2054
)
2055
2055
2056
2056
def _check_name (self , node_type , name , node , confidence = interfaces .HIGH ):
2057
- """check for a name using the type's regexp"""
2057
+ """Check for a name using the type's regexp"""
2058
2058
non_ascii_match = self ._non_ascii_rgx_compiled .match (name )
2059
2059
if non_ascii_match is not None :
2060
2060
self ._raise_name_warning (
@@ -2273,7 +2273,7 @@ def _check_docstring(
2273
2273
2274
2274
2275
2275
class PassChecker (_BasicChecker ):
2276
- """check if the pass statement is really necessary"""
2276
+ """Check if the pass statement is really necessary"""
2277
2277
2278
2278
msgs = {
2279
2279
"W0107" : (
0 commit comments