Method: pylint.checkers.variables.VariablesChecker._should_node_be_skipped
Calls: 24356, Exceptions: 0, Paths: 10Back
Path 1: 11594 calls (0.48)
Name (11504) AssignName (78) DelName (12)
NamesConsumer (11594)
True (5832) False (5762)
False (11594)
1def _should_node_be_skipped(
2 self, node: nodes.Name, consumer: NamesConsumer, is_start_index: bool
3 ) -> bool:
4 """Tests a consumer and node for various conditions in which the node shouldn't
5 be checked for the undefined-variable and used-before-assignment checks.
6 """
7 if consumer.scope_type == "class":
8 # The list of base classes in the class definition is not part
9 # of the class body.
10 # If the current scope is a class scope but it's not the inner
11 # scope, ignore it. This prevents to access this scope instead of
12 # the globals one in function members when there are some common
13 # names.
14 if utils.is_ancestor_name(consumer.node, node) or (
15 not is_start_index and self._ignore_class_scope(node)
16 ):
17 return True
18
19 # Ignore inner class scope for keywords in class definition
20 if isinstance(node.parent, nodes.Keyword) and isinstance(
21 node.parent.parent, nodes.ClassDef
22 ):
23 return True
24
25 elif consumer.scope_type == "function" and self._defined_in_function_definition(
26 node, consumer.node
27 ):
28 # If the name node is used as a function default argument's value or as
29 # a decorator, then start from the parent frame of the function instead
30 # of the function frame - and thus open an inner class scope
31 return True
32
33 elif consumer.scope_type == "lambda" and utils.is_default_argument(
34 node, consumer.node
35 ):
36 return True
37
38 return False
Path 2: 8414 calls (0.35)
Name (8249) AssignName (161) DelName (4)
NamesConsumer (8414)
True (8103) False (311)
False (8414)
1def _should_node_be_skipped(
2 self, node: nodes.Name, consumer: NamesConsumer, is_start_index: bool
3 ) -> bool:
4 """Tests a consumer and node for various conditions in which the node shouldn't
5 be checked for the undefined-variable and used-before-assignment checks.
6 """
7 if consumer.scope_type == "class":
8 # The list of base classes in the class definition is not part
9 # of the class body.
10 # If the current scope is a class scope but it's not the inner
11 # scope, ignore it. This prevents to access this scope instead of
12 # the globals one in function members when there are some common
13 # names.
14 if utils.is_ancestor_name(consumer.node, node) or (
15 not is_start_index and self._ignore_class_scope(node)
16 ):
17 return True
18
19 # Ignore inner class scope for keywords in class definition
20 if isinstance(node.parent, nodes.Keyword) and isinstance(
21 node.parent.parent, nodes.ClassDef
22 ):
23 return True
24
25 elif consumer.scope_type == "function" and self._defined_in_function_definition(
26 node, consumer.node
27 ):
28 # If the name node is used as a function default argument's value or as
29 # a decorator, then start from the parent frame of the function instead
30 # of the function frame - and thus open an inner class scope
31 return True
32
33 elif consumer.scope_type == "lambda" and utils.is_default_argument(
34 node, consumer.node
35 ):
36 return True
37
38 return False
Path 3: 1518 calls (0.06)
Name (1516) AssignName (2)
NamesConsumer (1518)
False (1518)
True (1518)
1def _should_node_be_skipped(
2 self, node: nodes.Name, consumer: NamesConsumer, is_start_index: bool
3 ) -> bool:
4 """Tests a consumer and node for various conditions in which the node shouldn't
5 be checked for the undefined-variable and used-before-assignment checks.
6 """
7 if consumer.scope_type == "class":
8 # The list of base classes in the class definition is not part
9 # of the class body.
10 # If the current scope is a class scope but it's not the inner
11 # scope, ignore it. This prevents to access this scope instead of
12 # the globals one in function members when there are some common
13 # names.
14 if utils.is_ancestor_name(consumer.node, node) or (
15 not is_start_index and self._ignore_class_scope(node)
16 ):
17 return True
18
19 # Ignore inner class scope for keywords in class definition
20 if isinstance(node.parent, nodes.Keyword) and isinstance(
21 node.parent.parent, nodes.ClassDef
22 ):
23 return True
24
25 elif consumer.scope_type == "function" and self._defined_in_function_definition(
26 node, consumer.node
27 ):
28 # If the name node is used as a function default argument's value or as
29 # a decorator, then start from the parent frame of the function instead
30 # of the function frame - and thus open an inner class scope
31 return True
32
33 elif consumer.scope_type == "lambda" and utils.is_default_argument(
34 node, consumer.node
35 ):
36 return True
37
38 return False
Path 4: 1200 calls (0.05)
Name (1200)
NamesConsumer (1200)
True (1192) False (8)
True (1200)
1def _should_node_be_skipped(
2 self, node: nodes.Name, consumer: NamesConsumer, is_start_index: bool
3 ) -> bool:
4 """Tests a consumer and node for various conditions in which the node shouldn't
5 be checked for the undefined-variable and used-before-assignment checks.
6 """
7 if consumer.scope_type == "class":
8 # The list of base classes in the class definition is not part
9 # of the class body.
10 # If the current scope is a class scope but it's not the inner
11 # scope, ignore it. This prevents to access this scope instead of
12 # the globals one in function members when there are some common
13 # names.
14 if utils.is_ancestor_name(consumer.node, node) or (
15 not is_start_index and self._ignore_class_scope(node)
16 ):
17 return True
18
19 # Ignore inner class scope for keywords in class definition
20 if isinstance(node.parent, nodes.Keyword) and isinstance(
21 node.parent.parent, nodes.ClassDef
22 ):
23 return True
24
25 elif consumer.scope_type == "function" and self._defined_in_function_definition(
26 node, consumer.node
27 ):
28 # If the name node is used as a function default argument's value or as
29 # a decorator, then start from the parent frame of the function instead
30 # of the function frame - and thus open an inner class scope
31 return True
32
33 elif consumer.scope_type == "lambda" and utils.is_default_argument(
34 node, consumer.node
35 ):
36 return True
37
38 return False
Path 5: 678 calls (0.03)
Name (678)
NamesConsumer (678)
True (677) False (1)
True (678)
1def _should_node_be_skipped(
2 self, node: nodes.Name, consumer: NamesConsumer, is_start_index: bool
3 ) -> bool:
4 """Tests a consumer and node for various conditions in which the node shouldn't
5 be checked for the undefined-variable and used-before-assignment checks.
6 """
7 if consumer.scope_type == "class":
8 # The list of base classes in the class definition is not part
9 # of the class body.
10 # If the current scope is a class scope but it's not the inner
11 # scope, ignore it. This prevents to access this scope instead of
12 # the globals one in function members when there are some common
13 # names.
14 if utils.is_ancestor_name(consumer.node, node) or (
15 not is_start_index and self._ignore_class_scope(node)
16 ):
17 return True
18
19 # Ignore inner class scope for keywords in class definition
20 if isinstance(node.parent, nodes.Keyword) and isinstance(
21 node.parent.parent, nodes.ClassDef
22 ):
23 return True
24
25 elif consumer.scope_type == "function" and self._defined_in_function_definition(
26 node, consumer.node
27 ):
28 # If the name node is used as a function default argument's value or as
29 # a decorator, then start from the parent frame of the function instead
30 # of the function frame - and thus open an inner class scope
31 return True
32
33 elif consumer.scope_type == "lambda" and utils.is_default_argument(
34 node, consumer.node
35 ):
36 return True
37
38 return False
Path 6: 557 calls (0.02)
Name (555) AssignName (2)
NamesConsumer (557)
True (501) False (56)
False (557)
1def _should_node_be_skipped(
2 self, node: nodes.Name, consumer: NamesConsumer, is_start_index: bool
3 ) -> bool:
4 """Tests a consumer and node for various conditions in which the node shouldn't
5 be checked for the undefined-variable and used-before-assignment checks.
6 """
7 if consumer.scope_type == "class":
8 # The list of base classes in the class definition is not part
9 # of the class body.
10 # If the current scope is a class scope but it's not the inner
11 # scope, ignore it. This prevents to access this scope instead of
12 # the globals one in function members when there are some common
13 # names.
14 if utils.is_ancestor_name(consumer.node, node) or (
15 not is_start_index and self._ignore_class_scope(node)
16 ):
17 return True
18
19 # Ignore inner class scope for keywords in class definition
20 if isinstance(node.parent, nodes.Keyword) and isinstance(
21 node.parent.parent, nodes.ClassDef
22 ):
23 return True
24
25 elif consumer.scope_type == "function" and self._defined_in_function_definition(
26 node, consumer.node
27 ):
28 # If the name node is used as a function default argument's value or as
29 # a decorator, then start from the parent frame of the function instead
30 # of the function frame - and thus open an inner class scope
31 return True
32
33 elif consumer.scope_type == "lambda" and utils.is_default_argument(
34 node, consumer.node
35 ):
36 return True
37
38 return False
Path 7: 366 calls (0.02)
Name (366)
NamesConsumer (366)
True (353) False (13)
False (366)
1def _should_node_be_skipped(
2 self, node: nodes.Name, consumer: NamesConsumer, is_start_index: bool
3 ) -> bool:
4 """Tests a consumer and node for various conditions in which the node shouldn't
5 be checked for the undefined-variable and used-before-assignment checks.
6 """
7 if consumer.scope_type == "class":
8 # The list of base classes in the class definition is not part
9 # of the class body.
10 # If the current scope is a class scope but it's not the inner
11 # scope, ignore it. This prevents to access this scope instead of
12 # the globals one in function members when there are some common
13 # names.
14 if utils.is_ancestor_name(consumer.node, node) or (
15 not is_start_index and self._ignore_class_scope(node)
16 ):
17 return True
18
19 # Ignore inner class scope for keywords in class definition
20 if isinstance(node.parent, nodes.Keyword) and isinstance(
21 node.parent.parent, nodes.ClassDef
22 ):
23 return True
24
25 elif consumer.scope_type == "function" and self._defined_in_function_definition(
26 node, consumer.node
27 ):
28 # If the name node is used as a function default argument's value or as
29 # a decorator, then start from the parent frame of the function instead
30 # of the function frame - and thus open an inner class scope
31 return True
32
33 elif consumer.scope_type == "lambda" and utils.is_default_argument(
34 node, consumer.node
35 ):
36 return True
37
38 return False
Path 8: 17 calls (0.0)
Name (17)
NamesConsumer (17)
True (17)
True (17)
1def _should_node_be_skipped(
2 self, node: nodes.Name, consumer: NamesConsumer, is_start_index: bool
3 ) -> bool:
4 """Tests a consumer and node for various conditions in which the node shouldn't
5 be checked for the undefined-variable and used-before-assignment checks.
6 """
7 if consumer.scope_type == "class":
8 # The list of base classes in the class definition is not part
9 # of the class body.
10 # If the current scope is a class scope but it's not the inner
11 # scope, ignore it. This prevents to access this scope instead of
12 # the globals one in function members when there are some common
13 # names.
14 if utils.is_ancestor_name(consumer.node, node) or (
15 not is_start_index and self._ignore_class_scope(node)
16 ):
17 return True
18
19 # Ignore inner class scope for keywords in class definition
20 if isinstance(node.parent, nodes.Keyword) and isinstance(
21 node.parent.parent, nodes.ClassDef
22 ):
23 return True
24
25 elif consumer.scope_type == "function" and self._defined_in_function_definition(
26 node, consumer.node
27 ):
28 # If the name node is used as a function default argument's value or as
29 # a decorator, then start from the parent frame of the function instead
30 # of the function frame - and thus open an inner class scope
31 return True
32
33 elif consumer.scope_type == "lambda" and utils.is_default_argument(
34 node, consumer.node
35 ):
36 return True
37
38 return False
Path 9: 9 calls (0.0)
Name (9)
NamesConsumer (9)
True (9)
False (9)
1def _should_node_be_skipped(
2 self, node: nodes.Name, consumer: NamesConsumer, is_start_index: bool
3 ) -> bool:
4 """Tests a consumer and node for various conditions in which the node shouldn't
5 be checked for the undefined-variable and used-before-assignment checks.
6 """
7 if consumer.scope_type == "class":
8 # The list of base classes in the class definition is not part
9 # of the class body.
10 # If the current scope is a class scope but it's not the inner
11 # scope, ignore it. This prevents to access this scope instead of
12 # the globals one in function members when there are some common
13 # names.
14 if utils.is_ancestor_name(consumer.node, node) or (
15 not is_start_index and self._ignore_class_scope(node)
16 ):
17 return True
18
19 # Ignore inner class scope for keywords in class definition
20 if isinstance(node.parent, nodes.Keyword) and isinstance(
21 node.parent.parent, nodes.ClassDef
22 ):
23 return True
24
25 elif consumer.scope_type == "function" and self._defined_in_function_definition(
26 node, consumer.node
27 ):
28 # If the name node is used as a function default argument's value or as
29 # a decorator, then start from the parent frame of the function instead
30 # of the function frame - and thus open an inner class scope
31 return True
32
33 elif consumer.scope_type == "lambda" and utils.is_default_argument(
34 node, consumer.node
35 ):
36 return True
37
38 return False
Path 10: 3 calls (0.0)
Name (3)
NamesConsumer (3)
True (3)
True (3)
1def _should_node_be_skipped(
2 self, node: nodes.Name, consumer: NamesConsumer, is_start_index: bool
3 ) -> bool:
4 """Tests a consumer and node for various conditions in which the node shouldn't
5 be checked for the undefined-variable and used-before-assignment checks.
6 """
7 if consumer.scope_type == "class":
8 # The list of base classes in the class definition is not part
9 # of the class body.
10 # If the current scope is a class scope but it's not the inner
11 # scope, ignore it. This prevents to access this scope instead of
12 # the globals one in function members when there are some common
13 # names.
14 if utils.is_ancestor_name(consumer.node, node) or (
15 not is_start_index and self._ignore_class_scope(node)
16 ):
17 return True
18
19 # Ignore inner class scope for keywords in class definition
20 if isinstance(node.parent, nodes.Keyword) and isinstance(
21 node.parent.parent, nodes.ClassDef
22 ):
23 return True
24
25 elif consumer.scope_type == "function" and self._defined_in_function_definition(
26 node, consumer.node
27 ):
28 # If the name node is used as a function default argument's value or as
29 # a decorator, then start from the parent frame of the function instead
30 # of the function frame - and thus open an inner class scope
31 return True
32
33 elif consumer.scope_type == "lambda" and utils.is_default_argument(
34 node, consumer.node
35 ):
36 return True
37
38 return False