Method: pylint.checkers.variables.VariablesChecker._check_unused_arguments
Calls: 981, Exceptions: 3, Paths: 11Back
Path 1: 535 calls (0.55)
'self' (483) 'cls' (49) 'truc' (1) 'bar_' (1) 'tastes_bitter' (1)
FunctionDef (526) AsyncFunctionDef (9)
AssignName (535)
['self'] (308) ['cls'] (28) ['self', 'param'] (22) ['self', 'index'] (9) ['self', 'format_spec'] (7) ['self', 'key'] (5) ['self', 'predicate'] (5) ['s...
set() (534) {'some_attr'} (1)
None (535)
1def _check_unused_arguments(
2 self,
3 name: str,
4 node: nodes.FunctionDef,
5 stmt: nodes.NodeNG,
6 argnames: list[str],
7 nonlocal_names: Iterable[str],
8 ) -> None:
9 is_method = node.is_method()
10 klass = node.parent.frame(future=True)
11 if is_method and isinstance(klass, nodes.ClassDef):
12 confidence = (
13 INFERENCE if utils.has_known_bases(klass) else INFERENCE_FAILURE
14 )
15 else:
16 confidence = HIGH
17
18 if is_method:
19 # Don't warn for the first argument of a (non static) method
20 if node.type != "staticmethod" and name == argnames[0]:
21 return
22 # Don't warn for argument of an overridden method
23 overridden = overridden_method(klass, node.name)
24 if overridden is not None and name in overridden.argnames():
25 return
26 if node.name in utils.PYMETHODS and node.name not in (
27 "__init__",
28 "__new__",
29 ):
30 return
31 # Don't check callback arguments
32 if any(
33 node.name.startswith(cb) or node.name.endswith(cb)
34 for cb in self.linter.config.callbacks
35 ):
36 return
37 # Don't check arguments of singledispatch.register function.
38 if utils.is_registered_in_singledispatch_function(node):
39 return
40
41 # Don't check function stubs created only for type information
42 if utils.is_overload_stub(node):
43 return
44
45 # Don't check protocol classes
46 if utils.is_protocol_class(klass):
47 return
48
49 if name in nonlocal_names:
50 return
51
52 self.add_message("unused-argument", args=name, node=stmt, confidence=confidence)
Path 2: 305 calls (0.31)
'self' (114) 'arg1' (18) 'arg2' (14) 'kwargs' (14) 'args' (11) 'x' (11) 'y' (11) 'doc_type' (10) 'name' (9) 'arg' (8)
FunctionDef (304) AsyncFunctionDef (1)
AssignName (279) Arguments (26)
['self'] (104) ['self', 'doc_type'] (20) ['x', 'y', 'z'] (18) ['arg1', 'args', 'arg2', 'kwargs'] (16) ['arg1', 'arg2', 'arg3', 'arg4'] (16) ['args', '...
set() (305)
1def _check_unused_arguments(
2 self,
3 name: str,
4 node: nodes.FunctionDef,
5 stmt: nodes.NodeNG,
6 argnames: list[str],
7 nonlocal_names: Iterable[str],
8 ) -> None:
9 is_method = node.is_method()
10 klass = node.parent.frame(future=True)
11 if is_method and isinstance(klass, nodes.ClassDef):
12 confidence = (
13 INFERENCE if utils.has_known_bases(klass) else INFERENCE_FAILURE
14 )
15 else:
16 confidence = HIGH
17
18 if is_method:
19 # Don't warn for the first argument of a (non static) method
20 if node.type != "staticmethod" and name == argnames[0]:
21 return
22 # Don't warn for argument of an overridden method
23 overridden = overridden_method(klass, node.name)
24 if overridden is not None and name in overridden.argnames():
25 return
26 if node.name in utils.PYMETHODS and node.name not in (
27 "__init__",
28 "__new__",
29 ):
30 return
31 # Don't check callback arguments
32 if any(
33 node.name.startswith(cb) or node.name.endswith(cb)
34 for cb in self.linter.config.callbacks
35 ):
36 return
37 # Don't check arguments of singledispatch.register function.
38 if utils.is_registered_in_singledispatch_function(node):
39 return
40
41 # Don't check function stubs created only for type information
42 if utils.is_overload_stub(node):
43 return
44
45 # Don't check protocol classes
46 if utils.is_protocol_class(klass):
47 return
48
49 if name in nonlocal_names:
50 return
51
52 self.add_message("unused-argument", args=name, node=stmt, confidence=confidence)
Path 3: 58 calls (0.06)
'value' (5) 'arg' (4) 'kwargs' (3) 'source' (3) 'obj' (3) 'a' (3) 'error' (2) 'item' (2) 'option' (2) 'second' (2)
FunctionDef (58)
AssignName (54) Arguments (4)
['self', 'a', 'b', 'c'] (6) ['self', 'value'] (5) ['self', 'arg'] (3) ['cls', 'source'] (3) ['self', 'obj'] (3) ['self', 'x', 'y', 'z'] (3) ['self', '...
set() (58)
1def _check_unused_arguments(
2 self,
3 name: str,
4 node: nodes.FunctionDef,
5 stmt: nodes.NodeNG,
6 argnames: list[str],
7 nonlocal_names: Iterable[str],
8 ) -> None:
9 is_method = node.is_method()
10 klass = node.parent.frame(future=True)
11 if is_method and isinstance(klass, nodes.ClassDef):
12 confidence = (
13 INFERENCE if utils.has_known_bases(klass) else INFERENCE_FAILURE
14 )
15 else:
16 confidence = HIGH
17
18 if is_method:
19 # Don't warn for the first argument of a (non static) method
20 if node.type != "staticmethod" and name == argnames[0]:
21 return
22 # Don't warn for argument of an overridden method
23 overridden = overridden_method(klass, node.name)
24 if overridden is not None and name in overridden.argnames():
25 return
26 if node.name in utils.PYMETHODS and node.name not in (
27 "__init__",
28 "__new__",
29 ):
30 return
31 # Don't check callback arguments
32 if any(
33 node.name.startswith(cb) or node.name.endswith(cb)
34 for cb in self.linter.config.callbacks
35 ):
36 return
37 # Don't check arguments of singledispatch.register function.
38 if utils.is_registered_in_singledispatch_function(node):
39 return
40
41 # Don't check function stubs created only for type information
42 if utils.is_overload_stub(node):
43 return
44
45 # Don't check protocol classes
46 if utils.is_protocol_class(klass):
47 return
48
49 if name in nonlocal_names:
50 return
51
52 self.add_message("unused-argument", args=name, node=stmt, confidence=confidence)
Path 4: 40 calls (0.04)
'format_spec' (8) 'index' (6) 'other' (4) 'argv' (3) 'cls' (2) 'instance' (2) 'owner' (2) 'exc_type' (2) 'exc_value' (2) 'traceback' (2)
FunctionDef (40)
AssignName (40)
['self', 'format_spec'] (7) ['self', 'exc_type', 'exc_value', 'traceback'] (6) ['self', 'index'] (6) ['self', 'instance', 'owner'] (4) ['self', 'inst'...
set() (40)
None (40)
1def _check_unused_arguments(
2 self,
3 name: str,
4 node: nodes.FunctionDef,
5 stmt: nodes.NodeNG,
6 argnames: list[str],
7 nonlocal_names: Iterable[str],
8 ) -> None:
9 is_method = node.is_method()
10 klass = node.parent.frame(future=True)
11 if is_method and isinstance(klass, nodes.ClassDef):
12 confidence = (
13 INFERENCE if utils.has_known_bases(klass) else INFERENCE_FAILURE
14 )
15 else:
16 confidence = HIGH
17
18 if is_method:
19 # Don't warn for the first argument of a (non static) method
20 if node.type != "staticmethod" and name == argnames[0]:
21 return
22 # Don't warn for argument of an overridden method
23 overridden = overridden_method(klass, node.name)
24 if overridden is not None and name in overridden.argnames():
25 return
26 if node.name in utils.PYMETHODS and node.name not in (
27 "__init__",
28 "__new__",
29 ):
30 return
31 # Don't check callback arguments
32 if any(
33 node.name.startswith(cb) or node.name.endswith(cb)
34 for cb in self.linter.config.callbacks
35 ):
36 return
37 # Don't check arguments of singledispatch.register function.
38 if utils.is_registered_in_singledispatch_function(node):
39 return
40
41 # Don't check function stubs created only for type information
42 if utils.is_overload_stub(node):
43 return
44
45 # Don't check protocol classes
46 if utils.is_protocol_class(klass):
47 return
48
49 if name in nonlocal_names:
50 return
51
52 self.add_message("unused-argument", args=name, node=stmt, confidence=confidence)
Path 5: 16 calls (0.02)
'num' (2) 'arg1' (1) 'name' (1) 'start' (1) 'count' (1) 'last_values' (1) 'arg' (1) 'kwargs' (1) 'param' (1) 'fillchar' (1)
FunctionDef (16)
AssignName (15) Arguments (1)
['name', 'start', 'count', 'last_values'] (4) ['self', 'num'] (2) ['self', 'aaa', 'aab', 'aac'] (2) ['self', 'arg2', 'arg1'] (1) ['self', 'arg', 'valu...
set() (16)
None (16)
1def _check_unused_arguments(
2 self,
3 name: str,
4 node: nodes.FunctionDef,
5 stmt: nodes.NodeNG,
6 argnames: list[str],
7 nonlocal_names: Iterable[str],
8 ) -> None:
9 is_method = node.is_method()
10 klass = node.parent.frame(future=True)
11 if is_method and isinstance(klass, nodes.ClassDef):
12 confidence = (
13 INFERENCE if utils.has_known_bases(klass) else INFERENCE_FAILURE
14 )
15 else:
16 confidence = HIGH
17
18 if is_method:
19 # Don't warn for the first argument of a (non static) method
20 if node.type != "staticmethod" and name == argnames[0]:
21 return
22 # Don't warn for argument of an overridden method
23 overridden = overridden_method(klass, node.name)
24 if overridden is not None and name in overridden.argnames():
25 return
26 if node.name in utils.PYMETHODS and node.name not in (
27 "__init__",
28 "__new__",
29 ):
30 return
31 # Don't check callback arguments
32 if any(
33 node.name.startswith(cb) or node.name.endswith(cb)
34 for cb in self.linter.config.callbacks
35 ):
36 return
37 # Don't check arguments of singledispatch.register function.
38 if utils.is_registered_in_singledispatch_function(node):
39 return
40
41 # Don't check function stubs created only for type information
42 if utils.is_overload_stub(node):
43 return
44
45 # Don't check protocol classes
46 if utils.is_protocol_class(klass):
47 return
48
49 if name in nonlocal_names:
50 return
51
52 self.add_message("unused-argument", args=name, node=stmt, confidence=confidence)
Path 6: 10 calls (0.01)
'arg' (6) 'arg1' (2) 'data' (2)
FunctionDef (10)
AssignName (10)
['arg'] (6) ['arg1'] (2) ['data'] (2)
set() (10)
None (10)
1def _check_unused_arguments(
2 self,
3 name: str,
4 node: nodes.FunctionDef,
5 stmt: nodes.NodeNG,
6 argnames: list[str],
7 nonlocal_names: Iterable[str],
8 ) -> None:
9 is_method = node.is_method()
10 klass = node.parent.frame(future=True)
11 if is_method and isinstance(klass, nodes.ClassDef):
12 confidence = (
13 INFERENCE if utils.has_known_bases(klass) else INFERENCE_FAILURE
14 )
15 else:
16 confidence = HIGH
17
18 if is_method:
19 # Don't warn for the first argument of a (non static) method
20 if node.type != "staticmethod" and name == argnames[0]:
21 return
22 # Don't warn for argument of an overridden method
23 overridden = overridden_method(klass, node.name)
24 if overridden is not None and name in overridden.argnames():
25 return
26 if node.name in utils.PYMETHODS and node.name not in (
27 "__init__",
28 "__new__",
29 ):
30 return
31 # Don't check callback arguments
32 if any(
33 node.name.startswith(cb) or node.name.endswith(cb)
34 for cb in self.linter.config.callbacks
35 ):
36 return
37 # Don't check arguments of singledispatch.register function.
38 if utils.is_registered_in_singledispatch_function(node):
39 return
40
41 # Don't check function stubs created only for type information
42 if utils.is_overload_stub(node):
43 return
44
45 # Don't check protocol classes
46 if utils.is_protocol_class(klass):
47 return
48
49 if name in nonlocal_names:
50 return
51
52 self.add_message("unused-argument", args=name, node=stmt, confidence=confidence)
Path 7: 6 calls (0.01)
'var' (2) 'option' (2) 'param' (2)
FunctionDef (6)
AssignName (6)
['self', 'var'] (2) ['self', 'option'] (2) ['self', 'param'] (2)
set() (6)
None (6)
1def _check_unused_arguments(
2 self,
3 name: str,
4 node: nodes.FunctionDef,
5 stmt: nodes.NodeNG,
6 argnames: list[str],
7 nonlocal_names: Iterable[str],
8 ) -> None:
9 is_method = node.is_method()
10 klass = node.parent.frame(future=True)
11 if is_method and isinstance(klass, nodes.ClassDef):
12 confidence = (
13 INFERENCE if utils.has_known_bases(klass) else INFERENCE_FAILURE
14 )
15 else:
16 confidence = HIGH
17
18 if is_method:
19 # Don't warn for the first argument of a (non static) method
20 if node.type != "staticmethod" and name == argnames[0]:
21 return
22 # Don't warn for argument of an overridden method
23 overridden = overridden_method(klass, node.name)
24 if overridden is not None and name in overridden.argnames():
25 return
26 if node.name in utils.PYMETHODS and node.name not in (
27 "__init__",
28 "__new__",
29 ):
30 return
31 # Don't check callback arguments
32 if any(
33 node.name.startswith(cb) or node.name.endswith(cb)
34 for cb in self.linter.config.callbacks
35 ):
36 return
37 # Don't check arguments of singledispatch.register function.
38 if utils.is_registered_in_singledispatch_function(node):
39 return
40
41 # Don't check function stubs created only for type information
42 if utils.is_overload_stub(node):
43 return
44
45 # Don't check protocol classes
46 if utils.is_protocol_class(klass):
47 return
48
49 if name in nonlocal_names:
50 return
51
52 self.add_message("unused-argument", args=name, node=stmt, confidence=confidence)
Path 8: 4 calls (0.0)
'arg' (3) 'verbose' (1)
FunctionDef (4)
AssignName (4)
['arg'] (3) ['arg', 'verbose'] (1)
set() (4)
None (4)
1def _check_unused_arguments(
2 self,
3 name: str,
4 node: nodes.FunctionDef,
5 stmt: nodes.NodeNG,
6 argnames: list[str],
7 nonlocal_names: Iterable[str],
8 ) -> None:
9 is_method = node.is_method()
10 klass = node.parent.frame(future=True)
11 if is_method and isinstance(klass, nodes.ClassDef):
12 confidence = (
13 INFERENCE if utils.has_known_bases(klass) else INFERENCE_FAILURE
14 )
15 else:
16 confidence = HIGH
17
18 if is_method:
19 # Don't warn for the first argument of a (non static) method
20 if node.type != "staticmethod" and name == argnames[0]:
21 return
22 # Don't warn for argument of an overridden method
23 overridden = overridden_method(klass, node.name)
24 if overridden is not None and name in overridden.argnames():
25 return
26 if node.name in utils.PYMETHODS and node.name not in (
27 "__init__",
28 "__new__",
29 ):
30 return
31 # Don't check callback arguments
32 if any(
33 node.name.startswith(cb) or node.name.endswith(cb)
34 for cb in self.linter.config.callbacks
35 ):
36 return
37 # Don't check arguments of singledispatch.register function.
38 if utils.is_registered_in_singledispatch_function(node):
39 return
40
41 # Don't check function stubs created only for type information
42 if utils.is_overload_stub(node):
43 return
44
45 # Don't check protocol classes
46 if utils.is_protocol_class(klass):
47 return
48
49 if name in nonlocal_names:
50 return
51
52 self.add_message("unused-argument", args=name, node=stmt, confidence=confidence)
Path 9: 3 calls (0.0)
'blob' (3)
FunctionDef (3)
AssignName (3)
['self', 'blob'] (3)
set() (3)
None (3)
1def _check_unused_arguments(
2 self,
3 name: str,
4 node: nodes.FunctionDef,
5 stmt: nodes.NodeNG,
6 argnames: list[str],
7 nonlocal_names: Iterable[str],
8 ) -> None:
9 is_method = node.is_method()
10 klass = node.parent.frame(future=True)
11 if is_method and isinstance(klass, nodes.ClassDef):
12 confidence = (
13 INFERENCE if utils.has_known_bases(klass) else INFERENCE_FAILURE
14 )
15 else:
16 confidence = HIGH
17
18 if is_method:
19 # Don't warn for the first argument of a (non static) method
20 if node.type != "staticmethod" and name == argnames[0]:
21 return
22 # Don't warn for argument of an overridden method
23 overridden = overridden_method(klass, node.name)
24 if overridden is not None and name in overridden.argnames():
25 return
26 if node.name in utils.PYMETHODS and node.name not in (
27 "__init__",
28 "__new__",
29 ):
30 return
31 # Don't check callback arguments
32 if any(
33 node.name.startswith(cb) or node.name.endswith(cb)
34 for cb in self.linter.config.callbacks
35 ):
36 return
37 # Don't check arguments of singledispatch.register function.
38 if utils.is_registered_in_singledispatch_function(node):
39 return
40
41 # Don't check function stubs created only for type information
42 if utils.is_overload_stub(node):
43 return
44
45 # Don't check protocol classes
46 if utils.is_protocol_class(klass):
47 return
48
49 if name in nonlocal_names:
50 return
51
52 self.add_message("unused-argument", args=name, node=stmt, confidence=confidence)
Path 10: 3 calls (0.0)
'abc' (2) 'defg' (1)
FunctionDef (3)
AssignName (3)
['abc', 'defg'] (2) ['abc'] (1)
set() (3)
None (3)
GeneratorExit (3)
1def _check_unused_arguments(
2 self,
3 name: str,
4 node: nodes.FunctionDef,
5 stmt: nodes.NodeNG,
6 argnames: list[str],
7 nonlocal_names: Iterable[str],
8 ) -> None:
9 is_method = node.is_method()
10 klass = node.parent.frame(future=True)
11 if is_method and isinstance(klass, nodes.ClassDef):
12 confidence = (
13 INFERENCE if utils.has_known_bases(klass) else INFERENCE_FAILURE
14 )
15 else:
16 confidence = HIGH
17
18 if is_method:
19 # Don't warn for the first argument of a (non static) method
20 if node.type != "staticmethod" and name == argnames[0]:
21 return
22 # Don't warn for argument of an overridden method
23 overridden = overridden_method(klass, node.name)
24 if overridden is not None and name in overridden.argnames():
25 return
26 if node.name in utils.PYMETHODS and node.name not in (
27 "__init__",
28 "__new__",
29 ):
30 return
31 # Don't check callback arguments
32 if any(
33 node.name.startswith(cb) or node.name.endswith(cb)
34 for cb in self.linter.config.callbacks
35 ):
36 return
37 # Don't check arguments of singledispatch.register function.
38 if utils.is_registered_in_singledispatch_function(node):
39 return
40
41 # Don't check function stubs created only for type information
42 if utils.is_overload_stub(node):
43 return
44
45 # Don't check protocol classes
46 if utils.is_protocol_class(klass):
47 return
48
49 if name in nonlocal_names:
50 return
51
52 self.add_message("unused-argument", args=name, node=stmt, confidence=confidence)
Path 11: 1 calls (0.0)
'initial' (1)
FunctionDef (1)
AssignName (1)
['initial'] (1)
{'initial'} (1)
None (1)
1def _check_unused_arguments(
2 self,
3 name: str,
4 node: nodes.FunctionDef,
5 stmt: nodes.NodeNG,
6 argnames: list[str],
7 nonlocal_names: Iterable[str],
8 ) -> None:
9 is_method = node.is_method()
10 klass = node.parent.frame(future=True)
11 if is_method and isinstance(klass, nodes.ClassDef):
12 confidence = (
13 INFERENCE if utils.has_known_bases(klass) else INFERENCE_FAILURE
14 )
15 else:
16 confidence = HIGH
17
18 if is_method:
19 # Don't warn for the first argument of a (non static) method
20 if node.type != "staticmethod" and name == argnames[0]:
21 return
22 # Don't warn for argument of an overridden method
23 overridden = overridden_method(klass, node.name)
24 if overridden is not None and name in overridden.argnames():
25 return
26 if node.name in utils.PYMETHODS and node.name not in (
27 "__init__",
28 "__new__",
29 ):
30 return
31 # Don't check callback arguments
32 if any(
33 node.name.startswith(cb) or node.name.endswith(cb)
34 for cb in self.linter.config.callbacks
35 ):
36 return
37 # Don't check arguments of singledispatch.register function.
38 if utils.is_registered_in_singledispatch_function(node):
39 return
40
41 # Don't check function stubs created only for type information
42 if utils.is_overload_stub(node):
43 return
44
45 # Don't check protocol classes
46 if utils.is_protocol_class(klass):
47 return
48
49 if name in nonlocal_names:
50 return
51
52 self.add_message("unused-argument", args=name, node=stmt, confidence=confidence)