Skip to content

Commit 517eac3

Browse files
nickdrozdjacobtylerwalls
authored andcommitted
Break up argument lines
1 parent 8630cfd commit 517eac3

File tree

1 file changed

+63
-24
lines changed

1 file changed

+63
-24
lines changed

pylint/checkers/variables.py

Lines changed: 63 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ def _get_unpacking_extra_info(node: nodes.Assign, inferred: InferenceResult) ->
174174

175175

176176
def _detect_global_scope(
177-
node: nodes.Name, frame: nodes.LocalsDictNodeNG, defframe: nodes.LocalsDictNodeNG
177+
node: nodes.Name,
178+
frame: nodes.LocalsDictNodeNG,
179+
defframe: nodes.LocalsDictNodeNG,
178180
) -> bool:
179181
"""Detect that the given frames share a global scope.
180182
@@ -324,7 +326,8 @@ def _find_frame_imports(name: str, frame: nodes.LocalsDictNodeNG) -> bool:
324326

325327

326328
def _import_name_is_global(
327-
stmt: nodes.Global | _base_nodes.ImportNode, global_names: set[str]
329+
stmt: nodes.Global | _base_nodes.ImportNode,
330+
global_names: set[str],
328331
) -> bool:
329332
for import_name, import_alias in stmt.names:
330333
# If the import uses an alias, check only that.
@@ -695,7 +698,9 @@ def get_next_to_consume(self, node: nodes.Name) -> list[nodes.NodeNG] | None:
695698
return found_nodes
696699

697700
def _inferred_to_define_name_raise_or_return(
698-
self, name: str, node: nodes.NodeNG
701+
self,
702+
name: str,
703+
node: nodes.NodeNG,
699704
) -> bool:
700705
"""Return True if there is a path under this `if_node`
701706
that is inferred to define `name`, raise, or return.
@@ -775,7 +780,9 @@ def _branch_handles_name(self, name: str, body: Iterable[nodes.NodeNG]) -> bool:
775780
)
776781

777782
def _uncertain_nodes_if_tests(
778-
self, found_nodes: list[nodes.NodeNG], node: nodes.NodeNG
783+
self,
784+
found_nodes: list[nodes.NodeNG],
785+
node: nodes.NodeNG,
779786
) -> list[nodes.NodeNG]:
780787
"""Identify nodes of uncertain execution because they are defined under if
781788
tests.
@@ -988,7 +995,8 @@ def _defines_name_raises_or_returns(name: str, node: nodes.NodeNG) -> bool:
988995

989996
@staticmethod
990997
def _defines_name_raises_or_returns_recursive(
991-
name: str, node: nodes.NodeNG
998+
name: str,
999+
node: nodes.NodeNG,
9921000
) -> bool:
9931001
"""Return True if some child of `node` defines the name `name`,
9941002
raises, or returns.
@@ -1012,7 +1020,8 @@ def _defines_name_raises_or_returns_recursive(
10121020

10131021
@staticmethod
10141022
def _check_loop_finishes_via_except(
1015-
node: nodes.NodeNG, other_node_try_except: nodes.Try
1023+
node: nodes.NodeNG,
1024+
other_node_try_except: nodes.Try,
10161025
) -> bool:
10171026
"""Check for a specific control flow scenario.
10181027
@@ -1055,7 +1064,8 @@ def _check_loop_finishes_via_except(
10551064
return False
10561065

10571066
def _try_in_loop_body(
1058-
other_node_try_except: nodes.Try, loop: nodes.For | nodes.While
1067+
other_node_try_except: nodes.Try,
1068+
loop: nodes.For | nodes.While,
10591069
) -> bool:
10601070
"""Return True if `other_node_try_except` is a descendant of `loop`."""
10611071
return any(
@@ -1085,7 +1095,8 @@ def _try_in_loop_body(
10851095

10861096
@staticmethod
10871097
def _recursive_search_for_continue_before_break(
1088-
stmt: _base_nodes.Statement, break_stmt: nodes.Break
1098+
stmt: _base_nodes.Statement,
1099+
break_stmt: nodes.Break,
10891100
) -> bool:
10901101
"""Return True if any Continue node can be found in descendants of `stmt`
10911102
before encountering `break_stmt`, ignoring any nested loops.
@@ -1105,7 +1116,8 @@ def _recursive_search_for_continue_before_break(
11051116

11061117
@staticmethod
11071118
def _uncertain_nodes_in_try_blocks_when_evaluating_except_blocks(
1108-
found_nodes: list[nodes.NodeNG], node_statement: _base_nodes.Statement
1119+
found_nodes: list[nodes.NodeNG],
1120+
node_statement: _base_nodes.Statement,
11091121
) -> list[nodes.NodeNG]:
11101122
"""Return any nodes in ``found_nodes`` that should be treated as uncertain.
11111123
@@ -1705,7 +1717,9 @@ def leave_excepthandler(self, node: nodes.ExceptHandler) -> None:
17051717
self._except_handler_names_queue.pop()
17061718

17071719
def _undefined_and_used_before_checker(
1708-
self, node: nodes.Name, stmt: nodes.NodeNG
1720+
self,
1721+
node: nodes.Name,
1722+
stmt: nodes.NodeNG,
17091723
) -> None:
17101724
frame = stmt.scope()
17111725
start_index = len(self._to_consume) - 1
@@ -1753,7 +1767,10 @@ def _undefined_and_used_before_checker(
17531767
self.add_message("undefined-variable", args=node.name, node=node)
17541768

17551769
def _should_node_be_skipped(
1756-
self, node: nodes.Name, consumer: NamesConsumer, is_start_index: bool
1770+
self,
1771+
node: nodes.Name,
1772+
consumer: NamesConsumer,
1773+
is_start_index: bool,
17571774
) -> bool:
17581775
"""Tests a consumer and node for various conditions in which the node shouldn't
17591776
be checked for the undefined-variable and used-before-assignment checks.
@@ -1995,7 +2012,9 @@ def _check_consumer(
19952012
return (VariableVisitConsumerAction.RETURN, found_nodes)
19962013

19972014
def _report_unfound_name_definition(
1998-
self, node: nodes.NodeNG, current_consumer: NamesConsumer
2015+
self,
2016+
node: nodes.NodeNG,
2017+
current_consumer: NamesConsumer,
19992018
) -> None:
20002019
"""Reports used-before-assignment when all name definition nodes
20012020
get filtered out by NamesConsumer.
@@ -2034,7 +2053,9 @@ def _report_unfound_name_definition(
20342053
)
20352054

20362055
def _filter_type_checking_import_from_consumption(
2037-
self, node: nodes.NodeNG, nodes_to_consume: list[nodes.NodeNG]
2056+
self,
2057+
node: nodes.NodeNG,
2058+
nodes_to_consume: list[nodes.NodeNG],
20382059
) -> list[nodes.NodeNG]:
20392060
"""Do not consume type-checking import node as used-before-assignment
20402061
may invoke in different scopes.
@@ -2169,7 +2190,8 @@ def _allow_global_unused_variables(self) -> bool:
21692190

21702191
@staticmethod
21712192
def _defined_in_function_definition(
2172-
node: nodes.NodeNG, frame: nodes.NodeNG
2193+
node: nodes.NodeNG,
2194+
frame: nodes.NodeNG,
21732195
) -> bool:
21742196
in_annotation_or_default_or_decorator = False
21752197
if isinstance(frame, nodes.FunctionDef) and node.statement() is frame:
@@ -2192,7 +2214,8 @@ def _defined_in_function_definition(
21922214

21932215
@staticmethod
21942216
def _in_lambda_or_comprehension_body(
2195-
node: nodes.NodeNG, frame: nodes.NodeNG
2217+
node: nodes.NodeNG,
2218+
frame: nodes.NodeNG,
21962219
) -> bool:
21972220
"""Return True if node within a lambda/comprehension body (or similar) and thus
21982221
should not have access to class attributes in frame.
@@ -2404,7 +2427,8 @@ def _is_builtin(self, name: str) -> bool:
24042427

24052428
@staticmethod
24062429
def _is_only_type_assignment(
2407-
node: nodes.Name, defstmt: _base_nodes.Statement
2430+
node: nodes.Name,
2431+
defstmt: _base_nodes.Statement,
24082432
) -> bool:
24092433
"""Check if variable only gets assigned a type and never a value."""
24102434
if not isinstance(defstmt, nodes.AnnAssign) or defstmt.value:
@@ -2462,7 +2486,9 @@ def _is_only_type_assignment(
24622486

24632487
@staticmethod
24642488
def _is_first_level_self_reference(
2465-
node: nodes.Name, defstmt: nodes.ClassDef, found_nodes: list[nodes.NodeNG]
2489+
node: nodes.Name,
2490+
defstmt: nodes.ClassDef,
2491+
found_nodes: list[nodes.NodeNG],
24662492
) -> tuple[VariableVisitConsumerAction, list[nodes.NodeNG] | None]:
24672493
"""Check if a first level method's annotation or default values
24682494
refers to its own class, and return a consumer action.
@@ -2483,7 +2509,8 @@ def _is_first_level_self_reference(
24832509

24842510
@staticmethod
24852511
def _is_never_evaluated(
2486-
defnode: nodes.NamedExpr, defnode_parent: nodes.IfExp
2512+
defnode: nodes.NamedExpr,
2513+
defnode_parent: nodes.IfExp,
24872514
) -> bool:
24882515
"""Check if a NamedExpr is inside a side of if ... else that never
24892516
gets evaluated.
@@ -2798,7 +2825,9 @@ def _check_is_unused(
27982825
self.add_message(message_name, args=name, node=stmt)
27992826

28002827
def _is_name_ignored(
2801-
self, stmt: nodes.NodeNG, name: str
2828+
self,
2829+
stmt: nodes.NodeNG,
2830+
name: str,
28022831
) -> re.Pattern[str] | re.Match[str] | None:
28032832
authorized_rgx = self.linter.config.dummy_variables_rgx
28042833
if (
@@ -2963,7 +2992,8 @@ def _store_type_annotation_node(self, type_annotation: nodes.NodeNG) -> None:
29632992
)
29642993

29652994
def _store_type_annotation_names(
2966-
self, node: nodes.For | nodes.Assign | nodes.With
2995+
self,
2996+
node: nodes.For | nodes.Assign | nodes.With,
29672997
) -> None:
29682998
type_annotation = node.type_annotation
29692999
if not type_annotation:
@@ -3001,7 +3031,10 @@ def _check_self_cls_assign(self, node: nodes.Assign) -> None:
30013031
self.add_message("self-cls-assignment", node=node, args=(self_cls_name,))
30023032

30033033
def _check_unpacking(
3004-
self, inferred: InferenceResult, node: nodes.Assign, targets: list[nodes.NodeNG]
3034+
self,
3035+
inferred: InferenceResult,
3036+
node: nodes.Assign,
3037+
targets: list[nodes.NodeNG],
30053038
) -> None:
30063039
"""Check for unbalanced tuple unpacking
30073040
and unpacking non sequences.
@@ -3130,7 +3163,9 @@ def _check_module_attrs(
31303163
return None
31313164

31323165
def _check_all(
3133-
self, node: nodes.Module, not_consumed: dict[str, list[nodes.NodeNG]]
3166+
self,
3167+
node: nodes.Module,
3168+
not_consumed: dict[str, list[nodes.NodeNG]],
31343169
) -> None:
31353170
try:
31363171
assigned = next(node.igetattr("__all__"))
@@ -3298,7 +3333,9 @@ def _check_metaclasses(self, node: nodes.Module | nodes.FunctionDef) -> None:
32983333
scope_locals.pop(name, None)
32993334

33003335
def _check_classdef_metaclasses(
3301-
self, klass: nodes.ClassDef, parent_node: nodes.Module | nodes.FunctionDef
3336+
self,
3337+
klass: nodes.ClassDef,
3338+
parent_node: nodes.Module | nodes.FunctionDef,
33023339
) -> list[tuple[dict[str, list[nodes.NodeNG]], str]]:
33033340
if not klass._metaclass:
33043341
# Skip if this class doesn't use explicitly a metaclass, but inherits it from ancestors
@@ -3357,7 +3394,9 @@ def visit_subscript(self, node: nodes.Subscript) -> None:
33573394
self._check_potential_index_error(node, inferred_slice)
33583395

33593396
def _check_potential_index_error(
3360-
self, node: nodes.Subscript, inferred_slice: nodes.NodeNG | None
3397+
self,
3398+
node: nodes.Subscript,
3399+
inferred_slice: nodes.NodeNG | None,
33613400
) -> None:
33623401
"""Check for the potential-index-error message."""
33633402
# Currently we only check simple slices of a single integer

0 commit comments

Comments
 (0)