Method: pylint.checkers.variables.VariablesChecker.leave_functiondef
Calls: 3527, Exceptions: 0, Paths: 7Back
Path 1: 1925 calls (0.55)
FunctionDef (1893) AsyncFunctionDef (32)
1def leave_functiondef(self, node: nodes.FunctionDef) -> None:
2 """Leave function: check function's locals are consumed."""
3 self._check_metaclasses(node)
4
5 if node.type_comment_returns:
6 self._store_type_annotation_node(node.type_comment_returns)
7 if node.type_comment_args:
8 for argument_annotation in node.type_comment_args:
9 self._store_type_annotation_node(argument_annotation)
10
11 not_consumed = self._to_consume.pop().to_consume
12 if not (
13 self.linter.is_message_enabled("unused-variable")
14 or self.linter.is_message_enabled("possibly-unused-variable")
15 or self.linter.is_message_enabled("unused-argument")
16 ):
17 return
18
19 # Don't check arguments of function which are only raising an exception.
20 if utils.is_error(node):
21 return
22
23 # Don't check arguments of abstract methods or within an interface.
24 is_method = node.is_method()
25 if is_method and node.is_abstract():
26 return
27
28 global_names = _flattened_scope_names(node.nodes_of_class(nodes.Global))
29 nonlocal_names = _flattened_scope_names(node.nodes_of_class(nodes.Nonlocal))
30 comprehension_target_names: set[str] = set()
31
32 for comprehension_scope in node.nodes_of_class(nodes.ComprehensionScope):
33 for generator in comprehension_scope.generators:
34 for name in utils.find_assigned_names_recursive(generator.target):
35 comprehension_target_names.add(name)
36
37 for name, stmts in not_consumed.items():
38 self._check_is_unused(
39 name,
40 node,
41 stmts[0],
42 global_names,
43 nonlocal_names,
44 comprehension_target_names,
45 )
Path 2: 1067 calls (0.3)
FunctionDef (1053) AsyncFunctionDef (14)
1def leave_functiondef(self, node: nodes.FunctionDef) -> None:
2 """Leave function: check function's locals are consumed."""
3 self._check_metaclasses(node)
4
5 if node.type_comment_returns:
6 self._store_type_annotation_node(node.type_comment_returns)
7 if node.type_comment_args:
8 for argument_annotation in node.type_comment_args:
9 self._store_type_annotation_node(argument_annotation)
10
11 not_consumed = self._to_consume.pop().to_consume
12 if not (
13 self.linter.is_message_enabled("unused-variable")
14 or self.linter.is_message_enabled("possibly-unused-variable")
15 or self.linter.is_message_enabled("unused-argument")
16 ):
17 return
18
19 # Don't check arguments of function which are only raising an exception.
20 if utils.is_error(node):
21 return
22
23 # Don't check arguments of abstract methods or within an interface.
24 is_method = node.is_method()
25 if is_method and node.is_abstract():
26 return
27
28 global_names = _flattened_scope_names(node.nodes_of_class(nodes.Global))
29 nonlocal_names = _flattened_scope_names(node.nodes_of_class(nodes.Nonlocal))
30 comprehension_target_names: set[str] = set()
31
32 for comprehension_scope in node.nodes_of_class(nodes.ComprehensionScope):
33 for generator in comprehension_scope.generators:
34 for name in utils.find_assigned_names_recursive(generator.target):
35 comprehension_target_names.add(name)
36
37 for name, stmts in not_consumed.items():
38 self._check_is_unused(
39 name,
40 node,
41 stmts[0],
42 global_names,
43 nonlocal_names,
44 comprehension_target_names,
45 )
Path 3: 406 calls (0.12)
FunctionDef (402) AsyncFunctionDef (4)
None (406)
1def leave_functiondef(self, node: nodes.FunctionDef) -> None:
2 """Leave function: check function's locals are consumed."""
3 self._check_metaclasses(node)
4
5 if node.type_comment_returns:
6 self._store_type_annotation_node(node.type_comment_returns)
7 if node.type_comment_args:
8 for argument_annotation in node.type_comment_args:
9 self._store_type_annotation_node(argument_annotation)
10
11 not_consumed = self._to_consume.pop().to_consume
12 if not (
13 self.linter.is_message_enabled("unused-variable")
14 or self.linter.is_message_enabled("possibly-unused-variable")
15 or self.linter.is_message_enabled("unused-argument")
16 ):
17 return
18
19 # Don't check arguments of function which are only raising an exception.
20 if utils.is_error(node):
21 return
22
23 # Don't check arguments of abstract methods or within an interface.
24 is_method = node.is_method()
25 if is_method and node.is_abstract():
26 return
27
28 global_names = _flattened_scope_names(node.nodes_of_class(nodes.Global))
29 nonlocal_names = _flattened_scope_names(node.nodes_of_class(nodes.Nonlocal))
30 comprehension_target_names: set[str] = set()
31
32 for comprehension_scope in node.nodes_of_class(nodes.ComprehensionScope):
33 for generator in comprehension_scope.generators:
34 for name in utils.find_assigned_names_recursive(generator.target):
35 comprehension_target_names.add(name)
36
37 for name, stmts in not_consumed.items():
38 self._check_is_unused(
39 name,
40 node,
41 stmts[0],
42 global_names,
43 nonlocal_names,
44 comprehension_target_names,
45 )
Path 4: 70 calls (0.02)
FunctionDef (69) AsyncFunctionDef (1)
None (70)
1def leave_functiondef(self, node: nodes.FunctionDef) -> None:
2 """Leave function: check function's locals are consumed."""
3 self._check_metaclasses(node)
4
5 if node.type_comment_returns:
6 self._store_type_annotation_node(node.type_comment_returns)
7 if node.type_comment_args:
8 for argument_annotation in node.type_comment_args:
9 self._store_type_annotation_node(argument_annotation)
10
11 not_consumed = self._to_consume.pop().to_consume
12 if not (
13 self.linter.is_message_enabled("unused-variable")
14 or self.linter.is_message_enabled("possibly-unused-variable")
15 or self.linter.is_message_enabled("unused-argument")
16 ):
17 return
18
19 # Don't check arguments of function which are only raising an exception.
20 if utils.is_error(node):
21 return
22
23 # Don't check arguments of abstract methods or within an interface.
24 is_method = node.is_method()
25 if is_method and node.is_abstract():
26 return
27
28 global_names = _flattened_scope_names(node.nodes_of_class(nodes.Global))
29 nonlocal_names = _flattened_scope_names(node.nodes_of_class(nodes.Nonlocal))
30 comprehension_target_names: set[str] = set()
31
32 for comprehension_scope in node.nodes_of_class(nodes.ComprehensionScope):
33 for generator in comprehension_scope.generators:
34 for name in utils.find_assigned_names_recursive(generator.target):
35 comprehension_target_names.add(name)
36
37 for name, stmts in not_consumed.items():
38 self._check_is_unused(
39 name,
40 node,
41 stmts[0],
42 global_names,
43 nonlocal_names,
44 comprehension_target_names,
45 )
Path 5: 44 calls (0.01)
FunctionDef (43) AsyncFunctionDef (1)
1def leave_functiondef(self, node: nodes.FunctionDef) -> None:
2 """Leave function: check function's locals are consumed."""
3 self._check_metaclasses(node)
4
5 if node.type_comment_returns:
6 self._store_type_annotation_node(node.type_comment_returns)
7 if node.type_comment_args:
8 for argument_annotation in node.type_comment_args:
9 self._store_type_annotation_node(argument_annotation)
10
11 not_consumed = self._to_consume.pop().to_consume
12 if not (
13 self.linter.is_message_enabled("unused-variable")
14 or self.linter.is_message_enabled("possibly-unused-variable")
15 or self.linter.is_message_enabled("unused-argument")
16 ):
17 return
18
19 # Don't check arguments of function which are only raising an exception.
20 if utils.is_error(node):
21 return
22
23 # Don't check arguments of abstract methods or within an interface.
24 is_method = node.is_method()
25 if is_method and node.is_abstract():
26 return
27
28 global_names = _flattened_scope_names(node.nodes_of_class(nodes.Global))
29 nonlocal_names = _flattened_scope_names(node.nodes_of_class(nodes.Nonlocal))
30 comprehension_target_names: set[str] = set()
31
32 for comprehension_scope in node.nodes_of_class(nodes.ComprehensionScope):
33 for generator in comprehension_scope.generators:
34 for name in utils.find_assigned_names_recursive(generator.target):
35 comprehension_target_names.add(name)
36
37 for name, stmts in not_consumed.items():
38 self._check_is_unused(
39 name,
40 node,
41 stmts[0],
42 global_names,
43 nonlocal_names,
44 comprehension_target_names,
45 )
Path 6: 11 calls (0.0)
FunctionDef (9) AsyncFunctionDef (2)
1def leave_functiondef(self, node: nodes.FunctionDef) -> None:
2 """Leave function: check function's locals are consumed."""
3 self._check_metaclasses(node)
4
5 if node.type_comment_returns:
6 self._store_type_annotation_node(node.type_comment_returns)
7 if node.type_comment_args:
8 for argument_annotation in node.type_comment_args:
9 self._store_type_annotation_node(argument_annotation)
10
11 not_consumed = self._to_consume.pop().to_consume
12 if not (
13 self.linter.is_message_enabled("unused-variable")
14 or self.linter.is_message_enabled("possibly-unused-variable")
15 or self.linter.is_message_enabled("unused-argument")
16 ):
17 return
18
19 # Don't check arguments of function which are only raising an exception.
20 if utils.is_error(node):
21 return
22
23 # Don't check arguments of abstract methods or within an interface.
24 is_method = node.is_method()
25 if is_method and node.is_abstract():
26 return
27
28 global_names = _flattened_scope_names(node.nodes_of_class(nodes.Global))
29 nonlocal_names = _flattened_scope_names(node.nodes_of_class(nodes.Nonlocal))
30 comprehension_target_names: set[str] = set()
31
32 for comprehension_scope in node.nodes_of_class(nodes.ComprehensionScope):
33 for generator in comprehension_scope.generators:
34 for name in utils.find_assigned_names_recursive(generator.target):
35 comprehension_target_names.add(name)
36
37 for name, stmts in not_consumed.items():
38 self._check_is_unused(
39 name,
40 node,
41 stmts[0],
42 global_names,
43 nonlocal_names,
44 comprehension_target_names,
45 )
Path 7: 4 calls (0.0)
FunctionDef (4)
1def leave_functiondef(self, node: nodes.FunctionDef) -> None:
2 """Leave function: check function's locals are consumed."""
3 self._check_metaclasses(node)
4
5 if node.type_comment_returns:
6 self._store_type_annotation_node(node.type_comment_returns)
7 if node.type_comment_args:
8 for argument_annotation in node.type_comment_args:
9 self._store_type_annotation_node(argument_annotation)
10
11 not_consumed = self._to_consume.pop().to_consume
12 if not (
13 self.linter.is_message_enabled("unused-variable")
14 or self.linter.is_message_enabled("possibly-unused-variable")
15 or self.linter.is_message_enabled("unused-argument")
16 ):
17 return
18
19 # Don't check arguments of function which are only raising an exception.
20 if utils.is_error(node):
21 return
22
23 # Don't check arguments of abstract methods or within an interface.
24 is_method = node.is_method()
25 if is_method and node.is_abstract():
26 return
27
28 global_names = _flattened_scope_names(node.nodes_of_class(nodes.Global))
29 nonlocal_names = _flattened_scope_names(node.nodes_of_class(nodes.Nonlocal))
30 comprehension_target_names: set[str] = set()
31
32 for comprehension_scope in node.nodes_of_class(nodes.ComprehensionScope):
33 for generator in comprehension_scope.generators:
34 for name in utils.find_assigned_names_recursive(generator.target):
35 comprehension_target_names.add(name)
36
37 for name, stmts in not_consumed.items():
38 self._check_is_unused(
39 name,
40 node,
41 stmts[0],
42 global_names,
43 nonlocal_names,
44 comprehension_target_names,
45 )