Method: pylint.checkers.variables.NamesConsumer._uncertain_nodes_in_false_tests
Calls: 6202, Exceptions: 27, Paths: 24Back
Path 1: 3890 calls (0.63)
list (3890)
Name (3818) AssignName (72)
[] (3890)
1def _uncertain_nodes_in_false_tests(
2 self, found_nodes: list[nodes.NodeNG], node: nodes.NodeNG
3 ) -> list[nodes.NodeNG]:
4 """Identify nodes of uncertain execution because they are defined under
5 tests that evaluate false.
6
7 Don't identify a node if there is a collectively exhaustive set of paths
8 that define the name, raise, or return (e.g. every if/else branch).
9 """
10 uncertain_nodes = []
11 for other_node in found_nodes:
12 if in_type_checking_block(other_node):
13 continue
14
15 if not isinstance(other_node, nodes.AssignName):
16 continue
17
18 closest_if = utils.get_node_first_ancestor_of_type(other_node, nodes.If)
19 if closest_if is None:
20 continue
21 if node.frame() is not closest_if.frame():
22 continue
23 if closest_if is not None and closest_if.parent_of(node):
24 continue
25
26 # Name defined in every if/else branch
27 if NamesConsumer._exhaustively_define_name_raise_or_return(
28 other_node.name, closest_if
29 ):
30 continue
31
32 # Higher-level if already determined to be always false
33 if any(
34 if_node.parent_of(closest_if)
35 for if_node in self._if_nodes_deemed_uncertain
36 ):
37 uncertain_nodes.append(other_node)
38 continue
39
40 # All inferred values must test false
41 if isinstance(closest_if.test, nodes.NamedExpr):
42 test = closest_if.test.value
43 else:
44 test = closest_if.test
45 all_inferred = utils.infer_all(test)
46 if not all_inferred or not all(
47 isinstance(inferred, nodes.Const) and not inferred.value
48 for inferred in all_inferred
49 ):
50 continue
51
52 uncertain_nodes.append(other_node)
53 self._if_nodes_deemed_uncertain.add(closest_if)
54
55 return uncertain_nodes
Path 2: 2120 calls (0.34)
list (2120)
Name (2114) DelName (6)
[] (2120)
1def _uncertain_nodes_in_false_tests(
2 self, found_nodes: list[nodes.NodeNG], node: nodes.NodeNG
3 ) -> list[nodes.NodeNG]:
4 """Identify nodes of uncertain execution because they are defined under
5 tests that evaluate false.
6
7 Don't identify a node if there is a collectively exhaustive set of paths
8 that define the name, raise, or return (e.g. every if/else branch).
9 """
10 uncertain_nodes = []
11 for other_node in found_nodes:
12 if in_type_checking_block(other_node):
13 continue
14
15 if not isinstance(other_node, nodes.AssignName):
16 continue
17
18 closest_if = utils.get_node_first_ancestor_of_type(other_node, nodes.If)
19 if closest_if is None:
20 continue
21 if node.frame() is not closest_if.frame():
22 continue
23 if closest_if is not None and closest_if.parent_of(node):
24 continue
25
26 # Name defined in every if/else branch
27 if NamesConsumer._exhaustively_define_name_raise_or_return(
28 other_node.name, closest_if
29 ):
30 continue
31
32 # Higher-level if already determined to be always false
33 if any(
34 if_node.parent_of(closest_if)
35 for if_node in self._if_nodes_deemed_uncertain
36 ):
37 uncertain_nodes.append(other_node)
38 continue
39
40 # All inferred values must test false
41 if isinstance(closest_if.test, nodes.NamedExpr):
42 test = closest_if.test.value
43 else:
44 test = closest_if.test
45 all_inferred = utils.infer_all(test)
46 if not all_inferred or not all(
47 isinstance(inferred, nodes.Const) and not inferred.value
48 for inferred in all_inferred
49 ):
50 continue
51
52 uncertain_nodes.append(other_node)
53 self._if_nodes_deemed_uncertain.add(closest_if)
54
55 return uncertain_nodes
Path 3: 37 calls (0.01)
list (37)
Name (35) AssignName (2)
[] (37)
1def _uncertain_nodes_in_false_tests(
2 self, found_nodes: list[nodes.NodeNG], node: nodes.NodeNG
3 ) -> list[nodes.NodeNG]:
4 """Identify nodes of uncertain execution because they are defined under
5 tests that evaluate false.
6
7 Don't identify a node if there is a collectively exhaustive set of paths
8 that define the name, raise, or return (e.g. every if/else branch).
9 """
10 uncertain_nodes = []
11 for other_node in found_nodes:
12 if in_type_checking_block(other_node):
13 continue
14
15 if not isinstance(other_node, nodes.AssignName):
16 continue
17
18 closest_if = utils.get_node_first_ancestor_of_type(other_node, nodes.If)
19 if closest_if is None:
20 continue
21 if node.frame() is not closest_if.frame():
22 continue
23 if closest_if is not None and closest_if.parent_of(node):
24 continue
25
26 # Name defined in every if/else branch
27 if NamesConsumer._exhaustively_define_name_raise_or_return(
28 other_node.name, closest_if
29 ):
30 continue
31
32 # Higher-level if already determined to be always false
33 if any(
34 if_node.parent_of(closest_if)
35 for if_node in self._if_nodes_deemed_uncertain
36 ):
37 uncertain_nodes.append(other_node)
38 continue
39
40 # All inferred values must test false
41 if isinstance(closest_if.test, nodes.NamedExpr):
42 test = closest_if.test.value
43 else:
44 test = closest_if.test
45 all_inferred = utils.infer_all(test)
46 if not all_inferred or not all(
47 isinstance(inferred, nodes.Const) and not inferred.value
48 for inferred in all_inferred
49 ):
50 continue
51
52 uncertain_nodes.append(other_node)
53 self._if_nodes_deemed_uncertain.add(closest_if)
54
55 return uncertain_nodes
Path 4: 29 calls (0.0)
list (29)
Name (22) DelName (6) AssignName (1)
[] (29)
1def _uncertain_nodes_in_false_tests(
2 self, found_nodes: list[nodes.NodeNG], node: nodes.NodeNG
3 ) -> list[nodes.NodeNG]:
4 """Identify nodes of uncertain execution because they are defined under
5 tests that evaluate false.
6
7 Don't identify a node if there is a collectively exhaustive set of paths
8 that define the name, raise, or return (e.g. every if/else branch).
9 """
10 uncertain_nodes = []
11 for other_node in found_nodes:
12 if in_type_checking_block(other_node):
13 continue
14
15 if not isinstance(other_node, nodes.AssignName):
16 continue
17
18 closest_if = utils.get_node_first_ancestor_of_type(other_node, nodes.If)
19 if closest_if is None:
20 continue
21 if node.frame() is not closest_if.frame():
22 continue
23 if closest_if is not None and closest_if.parent_of(node):
24 continue
25
26 # Name defined in every if/else branch
27 if NamesConsumer._exhaustively_define_name_raise_or_return(
28 other_node.name, closest_if
29 ):
30 continue
31
32 # Higher-level if already determined to be always false
33 if any(
34 if_node.parent_of(closest_if)
35 for if_node in self._if_nodes_deemed_uncertain
36 ):
37 uncertain_nodes.append(other_node)
38 continue
39
40 # All inferred values must test false
41 if isinstance(closest_if.test, nodes.NamedExpr):
42 test = closest_if.test.value
43 else:
44 test = closest_if.test
45 all_inferred = utils.infer_all(test)
46 if not all_inferred or not all(
47 isinstance(inferred, nodes.Const) and not inferred.value
48 for inferred in all_inferred
49 ):
50 continue
51
52 uncertain_nodes.append(other_node)
53 self._if_nodes_deemed_uncertain.add(closest_if)
54
55 return uncertain_nodes
Path 5: 21 calls (0.0)
list (21)
Name (21)
[] (21)
1def _uncertain_nodes_in_false_tests(
2 self, found_nodes: list[nodes.NodeNG], node: nodes.NodeNG
3 ) -> list[nodes.NodeNG]:
4 """Identify nodes of uncertain execution because they are defined under
5 tests that evaluate false.
6
7 Don't identify a node if there is a collectively exhaustive set of paths
8 that define the name, raise, or return (e.g. every if/else branch).
9 """
10 uncertain_nodes = []
11 for other_node in found_nodes:
12 if in_type_checking_block(other_node):
13 continue
14
15 if not isinstance(other_node, nodes.AssignName):
16 continue
17
18 closest_if = utils.get_node_first_ancestor_of_type(other_node, nodes.If)
19 if closest_if is None:
20 continue
21 if node.frame() is not closest_if.frame():
22 continue
23 if closest_if is not None and closest_if.parent_of(node):
24 continue
25
26 # Name defined in every if/else branch
27 if NamesConsumer._exhaustively_define_name_raise_or_return(
28 other_node.name, closest_if
29 ):
30 continue
31
32 # Higher-level if already determined to be always false
33 if any(
34 if_node.parent_of(closest_if)
35 for if_node in self._if_nodes_deemed_uncertain
36 ):
37 uncertain_nodes.append(other_node)
38 continue
39
40 # All inferred values must test false
41 if isinstance(closest_if.test, nodes.NamedExpr):
42 test = closest_if.test.value
43 else:
44 test = closest_if.test
45 all_inferred = utils.infer_all(test)
46 if not all_inferred or not all(
47 isinstance(inferred, nodes.Const) and not inferred.value
48 for inferred in all_inferred
49 ):
50 continue
51
52 uncertain_nodes.append(other_node)
53 self._if_nodes_deemed_uncertain.add(closest_if)
54
55 return uncertain_nodes
Path 6: 20 calls (0.0)
list (20)
Name (20)
[] (20)
1def _uncertain_nodes_in_false_tests(
2 self, found_nodes: list[nodes.NodeNG], node: nodes.NodeNG
3 ) -> list[nodes.NodeNG]:
4 """Identify nodes of uncertain execution because they are defined under
5 tests that evaluate false.
6
7 Don't identify a node if there is a collectively exhaustive set of paths
8 that define the name, raise, or return (e.g. every if/else branch).
9 """
10 uncertain_nodes = []
11 for other_node in found_nodes:
12 if in_type_checking_block(other_node):
13 continue
14
15 if not isinstance(other_node, nodes.AssignName):
16 continue
17
18 closest_if = utils.get_node_first_ancestor_of_type(other_node, nodes.If)
19 if closest_if is None:
20 continue
21 if node.frame() is not closest_if.frame():
22 continue
23 if closest_if is not None and closest_if.parent_of(node):
24 continue
25
26 # Name defined in every if/else branch
27 if NamesConsumer._exhaustively_define_name_raise_or_return(
28 other_node.name, closest_if
29 ):
30 continue
31
32 # Higher-level if already determined to be always false
33 if any(
34 if_node.parent_of(closest_if)
35 for if_node in self._if_nodes_deemed_uncertain
36 ):
37 uncertain_nodes.append(other_node)
38 continue
39
40 # All inferred values must test false
41 if isinstance(closest_if.test, nodes.NamedExpr):
42 test = closest_if.test.value
43 else:
44 test = closest_if.test
45 all_inferred = utils.infer_all(test)
46 if not all_inferred or not all(
47 isinstance(inferred, nodes.Const) and not inferred.value
48 for inferred in all_inferred
49 ):
50 continue
51
52 uncertain_nodes.append(other_node)
53 self._if_nodes_deemed_uncertain.add(closest_if)
54
55 return uncertain_nodes
Path 7: 16 calls (0.0)
list (16)
Name (16)
[] (16)
1def _uncertain_nodes_in_false_tests(
2 self, found_nodes: list[nodes.NodeNG], node: nodes.NodeNG
3 ) -> list[nodes.NodeNG]:
4 """Identify nodes of uncertain execution because they are defined under
5 tests that evaluate false.
6
7 Don't identify a node if there is a collectively exhaustive set of paths
8 that define the name, raise, or return (e.g. every if/else branch).
9 """
10 uncertain_nodes = []
11 for other_node in found_nodes:
12 if in_type_checking_block(other_node):
13 continue
14
15 if not isinstance(other_node, nodes.AssignName):
16 continue
17
18 closest_if = utils.get_node_first_ancestor_of_type(other_node, nodes.If)
19 if closest_if is None:
20 continue
21 if node.frame() is not closest_if.frame():
22 continue
23 if closest_if is not None and closest_if.parent_of(node):
24 continue
25
26 # Name defined in every if/else branch
27 if NamesConsumer._exhaustively_define_name_raise_or_return(
28 other_node.name, closest_if
29 ):
30 continue
31
32 # Higher-level if already determined to be always false
33 if any(
34 if_node.parent_of(closest_if)
35 for if_node in self._if_nodes_deemed_uncertain
36 ):
37 uncertain_nodes.append(other_node)
38 continue
39
40 # All inferred values must test false
41 if isinstance(closest_if.test, nodes.NamedExpr):
42 test = closest_if.test.value
43 else:
44 test = closest_if.test
45 all_inferred = utils.infer_all(test)
46 if not all_inferred or not all(
47 isinstance(inferred, nodes.Const) and not inferred.value
48 for inferred in all_inferred
49 ):
50 continue
51
52 uncertain_nodes.append(other_node)
53 self._if_nodes_deemed_uncertain.add(closest_if)
54
55 return uncertain_nodes
Path 8: 15 calls (0.0)
list (15)
Name (14) AssignName (1)
[] (15)
GeneratorExit (15)
1def _uncertain_nodes_in_false_tests(
2 self, found_nodes: list[nodes.NodeNG], node: nodes.NodeNG
3 ) -> list[nodes.NodeNG]:
4 """Identify nodes of uncertain execution because they are defined under
5 tests that evaluate false.
6
7 Don't identify a node if there is a collectively exhaustive set of paths
8 that define the name, raise, or return (e.g. every if/else branch).
9 """
10 uncertain_nodes = []
11 for other_node in found_nodes:
12 if in_type_checking_block(other_node):
13 continue
14
15 if not isinstance(other_node, nodes.AssignName):
16 continue
17
18 closest_if = utils.get_node_first_ancestor_of_type(other_node, nodes.If)
19 if closest_if is None:
20 continue
21 if node.frame() is not closest_if.frame():
22 continue
23 if closest_if is not None and closest_if.parent_of(node):
24 continue
25
26 # Name defined in every if/else branch
27 if NamesConsumer._exhaustively_define_name_raise_or_return(
28 other_node.name, closest_if
29 ):
30 continue
31
32 # Higher-level if already determined to be always false
33 if any(
34 if_node.parent_of(closest_if)
35 for if_node in self._if_nodes_deemed_uncertain
36 ):
37 uncertain_nodes.append(other_node)
38 continue
39
40 # All inferred values must test false
41 if isinstance(closest_if.test, nodes.NamedExpr):
42 test = closest_if.test.value
43 else:
44 test = closest_if.test
45 all_inferred = utils.infer_all(test)
46 if not all_inferred or not all(
47 isinstance(inferred, nodes.Const) and not inferred.value
48 for inferred in all_inferred
49 ):
50 continue
51
52 uncertain_nodes.append(other_node)
53 self._if_nodes_deemed_uncertain.add(closest_if)
54
55 return uncertain_nodes
Path 9: 13 calls (0.0)
list (13)
Name (10) AssignName (3)
[] (13)
1def _uncertain_nodes_in_false_tests(
2 self, found_nodes: list[nodes.NodeNG], node: nodes.NodeNG
3 ) -> list[nodes.NodeNG]:
4 """Identify nodes of uncertain execution because they are defined under
5 tests that evaluate false.
6
7 Don't identify a node if there is a collectively exhaustive set of paths
8 that define the name, raise, or return (e.g. every if/else branch).
9 """
10 uncertain_nodes = []
11 for other_node in found_nodes:
12 if in_type_checking_block(other_node):
13 continue
14
15 if not isinstance(other_node, nodes.AssignName):
16 continue
17
18 closest_if = utils.get_node_first_ancestor_of_type(other_node, nodes.If)
19 if closest_if is None:
20 continue
21 if node.frame() is not closest_if.frame():
22 continue
23 if closest_if is not None and closest_if.parent_of(node):
24 continue
25
26 # Name defined in every if/else branch
27 if NamesConsumer._exhaustively_define_name_raise_or_return(
28 other_node.name, closest_if
29 ):
30 continue
31
32 # Higher-level if already determined to be always false
33 if any(
34 if_node.parent_of(closest_if)
35 for if_node in self._if_nodes_deemed_uncertain
36 ):
37 uncertain_nodes.append(other_node)
38 continue
39
40 # All inferred values must test false
41 if isinstance(closest_if.test, nodes.NamedExpr):
42 test = closest_if.test.value
43 else:
44 test = closest_if.test
45 all_inferred = utils.infer_all(test)
46 if not all_inferred or not all(
47 isinstance(inferred, nodes.Const) and not inferred.value
48 for inferred in all_inferred
49 ):
50 continue
51
52 uncertain_nodes.append(other_node)
53 self._if_nodes_deemed_uncertain.add(closest_if)
54
55 return uncertain_nodes
Path 10: 11 calls (0.0)
list (11)
Name (11)
[] (11)
1def _uncertain_nodes_in_false_tests(
2 self, found_nodes: list[nodes.NodeNG], node: nodes.NodeNG
3 ) -> list[nodes.NodeNG]:
4 """Identify nodes of uncertain execution because they are defined under
5 tests that evaluate false.
6
7 Don't identify a node if there is a collectively exhaustive set of paths
8 that define the name, raise, or return (e.g. every if/else branch).
9 """
10 uncertain_nodes = []
11 for other_node in found_nodes:
12 if in_type_checking_block(other_node):
13 continue
14
15 if not isinstance(other_node, nodes.AssignName):
16 continue
17
18 closest_if = utils.get_node_first_ancestor_of_type(other_node, nodes.If)
19 if closest_if is None:
20 continue
21 if node.frame() is not closest_if.frame():
22 continue
23 if closest_if is not None and closest_if.parent_of(node):
24 continue
25
26 # Name defined in every if/else branch
27 if NamesConsumer._exhaustively_define_name_raise_or_return(
28 other_node.name, closest_if
29 ):
30 continue
31
32 # Higher-level if already determined to be always false
33 if any(
34 if_node.parent_of(closest_if)
35 for if_node in self._if_nodes_deemed_uncertain
36 ):
37 uncertain_nodes.append(other_node)
38 continue
39
40 # All inferred values must test false
41 if isinstance(closest_if.test, nodes.NamedExpr):
42 test = closest_if.test.value
43 else:
44 test = closest_if.test
45 all_inferred = utils.infer_all(test)
46 if not all_inferred or not all(
47 isinstance(inferred, nodes.Const) and not inferred.value
48 for inferred in all_inferred
49 ):
50 continue
51
52 uncertain_nodes.append(other_node)
53 self._if_nodes_deemed_uncertain.add(closest_if)
54
55 return uncertain_nodes
Path 11: 5 calls (0.0)
list (5)
Name (5)
[] (5)
1def _uncertain_nodes_in_false_tests(
2 self, found_nodes: list[nodes.NodeNG], node: nodes.NodeNG
3 ) -> list[nodes.NodeNG]:
4 """Identify nodes of uncertain execution because they are defined under
5 tests that evaluate false.
6
7 Don't identify a node if there is a collectively exhaustive set of paths
8 that define the name, raise, or return (e.g. every if/else branch).
9 """
10 uncertain_nodes = []
11 for other_node in found_nodes:
12 if in_type_checking_block(other_node):
13 continue
14
15 if not isinstance(other_node, nodes.AssignName):
16 continue
17
18 closest_if = utils.get_node_first_ancestor_of_type(other_node, nodes.If)
19 if closest_if is None:
20 continue
21 if node.frame() is not closest_if.frame():
22 continue
23 if closest_if is not None and closest_if.parent_of(node):
24 continue
25
26 # Name defined in every if/else branch
27 if NamesConsumer._exhaustively_define_name_raise_or_return(
28 other_node.name, closest_if
29 ):
30 continue
31
32 # Higher-level if already determined to be always false
33 if any(
34 if_node.parent_of(closest_if)
35 for if_node in self._if_nodes_deemed_uncertain
36 ):
37 uncertain_nodes.append(other_node)
38 continue
39
40 # All inferred values must test false
41 if isinstance(closest_if.test, nodes.NamedExpr):
42 test = closest_if.test.value
43 else:
44 test = closest_if.test
45 all_inferred = utils.infer_all(test)
46 if not all_inferred or not all(
47 isinstance(inferred, nodes.Const) and not inferred.value
48 for inferred in all_inferred
49 ):
50 continue
51
52 uncertain_nodes.append(other_node)
53 self._if_nodes_deemed_uncertain.add(closest_if)
54
55 return uncertain_nodes
Path 12: 4 calls (0.0)
list (4)
Name (4)
[] (4)
GeneratorExit (4)
1def _uncertain_nodes_in_false_tests(
2 self, found_nodes: list[nodes.NodeNG], node: nodes.NodeNG
3 ) -> list[nodes.NodeNG]:
4 """Identify nodes of uncertain execution because they are defined under
5 tests that evaluate false.
6
7 Don't identify a node if there is a collectively exhaustive set of paths
8 that define the name, raise, or return (e.g. every if/else branch).
9 """
10 uncertain_nodes = []
11 for other_node in found_nodes:
12 if in_type_checking_block(other_node):
13 continue
14
15 if not isinstance(other_node, nodes.AssignName):
16 continue
17
18 closest_if = utils.get_node_first_ancestor_of_type(other_node, nodes.If)
19 if closest_if is None:
20 continue
21 if node.frame() is not closest_if.frame():
22 continue
23 if closest_if is not None and closest_if.parent_of(node):
24 continue
25
26 # Name defined in every if/else branch
27 if NamesConsumer._exhaustively_define_name_raise_or_return(
28 other_node.name, closest_if
29 ):
30 continue
31
32 # Higher-level if already determined to be always false
33 if any(
34 if_node.parent_of(closest_if)
35 for if_node in self._if_nodes_deemed_uncertain
36 ):
37 uncertain_nodes.append(other_node)
38 continue
39
40 # All inferred values must test false
41 if isinstance(closest_if.test, nodes.NamedExpr):
42 test = closest_if.test.value
43 else:
44 test = closest_if.test
45 all_inferred = utils.infer_all(test)
46 if not all_inferred or not all(
47 isinstance(inferred, nodes.Const) and not inferred.value
48 for inferred in all_inferred
49 ):
50 continue
51
52 uncertain_nodes.append(other_node)
53 self._if_nodes_deemed_uncertain.add(closest_if)
54
55 return uncertain_nodes
Path 13: 3 calls (0.0)
list (3)
Name (3)
list (3)
1def _uncertain_nodes_in_false_tests(
2 self, found_nodes: list[nodes.NodeNG], node: nodes.NodeNG
3 ) -> list[nodes.NodeNG]:
4 """Identify nodes of uncertain execution because they are defined under
5 tests that evaluate false.
6
7 Don't identify a node if there is a collectively exhaustive set of paths
8 that define the name, raise, or return (e.g. every if/else branch).
9 """
10 uncertain_nodes = []
11 for other_node in found_nodes:
12 if in_type_checking_block(other_node):
13 continue
14
15 if not isinstance(other_node, nodes.AssignName):
16 continue
17
18 closest_if = utils.get_node_first_ancestor_of_type(other_node, nodes.If)
19 if closest_if is None:
20 continue
21 if node.frame() is not closest_if.frame():
22 continue
23 if closest_if is not None and closest_if.parent_of(node):
24 continue
25
26 # Name defined in every if/else branch
27 if NamesConsumer._exhaustively_define_name_raise_or_return(
28 other_node.name, closest_if
29 ):
30 continue
31
32 # Higher-level if already determined to be always false
33 if any(
34 if_node.parent_of(closest_if)
35 for if_node in self._if_nodes_deemed_uncertain
36 ):
37 uncertain_nodes.append(other_node)
38 continue
39
40 # All inferred values must test false
41 if isinstance(closest_if.test, nodes.NamedExpr):
42 test = closest_if.test.value
43 else:
44 test = closest_if.test
45 all_inferred = utils.infer_all(test)
46 if not all_inferred or not all(
47 isinstance(inferred, nodes.Const) and not inferred.value
48 for inferred in all_inferred
49 ):
50 continue
51
52 uncertain_nodes.append(other_node)
53 self._if_nodes_deemed_uncertain.add(closest_if)
54
55 return uncertain_nodes
Path 14: 3 calls (0.0)
list (3)
Name (3)
list (3)
1def _uncertain_nodes_in_false_tests(
2 self, found_nodes: list[nodes.NodeNG], node: nodes.NodeNG
3 ) -> list[nodes.NodeNG]:
4 """Identify nodes of uncertain execution because they are defined under
5 tests that evaluate false.
6
7 Don't identify a node if there is a collectively exhaustive set of paths
8 that define the name, raise, or return (e.g. every if/else branch).
9 """
10 uncertain_nodes = []
11 for other_node in found_nodes:
12 if in_type_checking_block(other_node):
13 continue
14
15 if not isinstance(other_node, nodes.AssignName):
16 continue
17
18 closest_if = utils.get_node_first_ancestor_of_type(other_node, nodes.If)
19 if closest_if is None:
20 continue
21 if node.frame() is not closest_if.frame():
22 continue
23 if closest_if is not None and closest_if.parent_of(node):
24 continue
25
26 # Name defined in every if/else branch
27 if NamesConsumer._exhaustively_define_name_raise_or_return(
28 other_node.name, closest_if
29 ):
30 continue
31
32 # Higher-level if already determined to be always false
33 if any(
34 if_node.parent_of(closest_if)
35 for if_node in self._if_nodes_deemed_uncertain
36 ):
37 uncertain_nodes.append(other_node)
38 continue
39
40 # All inferred values must test false
41 if isinstance(closest_if.test, nodes.NamedExpr):
42 test = closest_if.test.value
43 else:
44 test = closest_if.test
45 all_inferred = utils.infer_all(test)
46 if not all_inferred or not all(
47 isinstance(inferred, nodes.Const) and not inferred.value
48 for inferred in all_inferred
49 ):
50 continue
51
52 uncertain_nodes.append(other_node)
53 self._if_nodes_deemed_uncertain.add(closest_if)
54
55 return uncertain_nodes
Path 15: 3 calls (0.0)
list (3)
Name (3)
[] (3)
GeneratorExit (3)
1def _uncertain_nodes_in_false_tests(
2 self, found_nodes: list[nodes.NodeNG], node: nodes.NodeNG
3 ) -> list[nodes.NodeNG]:
4 """Identify nodes of uncertain execution because they are defined under
5 tests that evaluate false.
6
7 Don't identify a node if there is a collectively exhaustive set of paths
8 that define the name, raise, or return (e.g. every if/else branch).
9 """
10 uncertain_nodes = []
11 for other_node in found_nodes:
12 if in_type_checking_block(other_node):
13 continue
14
15 if not isinstance(other_node, nodes.AssignName):
16 continue
17
18 closest_if = utils.get_node_first_ancestor_of_type(other_node, nodes.If)
19 if closest_if is None:
20 continue
21 if node.frame() is not closest_if.frame():
22 continue
23 if closest_if is not None and closest_if.parent_of(node):
24 continue
25
26 # Name defined in every if/else branch
27 if NamesConsumer._exhaustively_define_name_raise_or_return(
28 other_node.name, closest_if
29 ):
30 continue
31
32 # Higher-level if already determined to be always false
33 if any(
34 if_node.parent_of(closest_if)
35 for if_node in self._if_nodes_deemed_uncertain
36 ):
37 uncertain_nodes.append(other_node)
38 continue
39
40 # All inferred values must test false
41 if isinstance(closest_if.test, nodes.NamedExpr):
42 test = closest_if.test.value
43 else:
44 test = closest_if.test
45 all_inferred = utils.infer_all(test)
46 if not all_inferred or not all(
47 isinstance(inferred, nodes.Const) and not inferred.value
48 for inferred in all_inferred
49 ):
50 continue
51
52 uncertain_nodes.append(other_node)
53 self._if_nodes_deemed_uncertain.add(closest_if)
54
55 return uncertain_nodes
Path 16: 2 calls (0.0)
list (2)
Name (2)
[] (2)
1def _uncertain_nodes_in_false_tests(
2 self, found_nodes: list[nodes.NodeNG], node: nodes.NodeNG
3 ) -> list[nodes.NodeNG]:
4 """Identify nodes of uncertain execution because they are defined under
5 tests that evaluate false.
6
7 Don't identify a node if there is a collectively exhaustive set of paths
8 that define the name, raise, or return (e.g. every if/else branch).
9 """
10 uncertain_nodes = []
11 for other_node in found_nodes:
12 if in_type_checking_block(other_node):
13 continue
14
15 if not isinstance(other_node, nodes.AssignName):
16 continue
17
18 closest_if = utils.get_node_first_ancestor_of_type(other_node, nodes.If)
19 if closest_if is None:
20 continue
21 if node.frame() is not closest_if.frame():
22 continue
23 if closest_if is not None and closest_if.parent_of(node):
24 continue
25
26 # Name defined in every if/else branch
27 if NamesConsumer._exhaustively_define_name_raise_or_return(
28 other_node.name, closest_if
29 ):
30 continue
31
32 # Higher-level if already determined to be always false
33 if any(
34 if_node.parent_of(closest_if)
35 for if_node in self._if_nodes_deemed_uncertain
36 ):
37 uncertain_nodes.append(other_node)
38 continue
39
40 # All inferred values must test false
41 if isinstance(closest_if.test, nodes.NamedExpr):
42 test = closest_if.test.value
43 else:
44 test = closest_if.test
45 all_inferred = utils.infer_all(test)
46 if not all_inferred or not all(
47 isinstance(inferred, nodes.Const) and not inferred.value
48 for inferred in all_inferred
49 ):
50 continue
51
52 uncertain_nodes.append(other_node)
53 self._if_nodes_deemed_uncertain.add(closest_if)
54
55 return uncertain_nodes
Path 17: 2 calls (0.0)
list (2)
Name (2)
[] (2)
GeneratorExit (2)
1def _uncertain_nodes_in_false_tests(
2 self, found_nodes: list[nodes.NodeNG], node: nodes.NodeNG
3 ) -> list[nodes.NodeNG]:
4 """Identify nodes of uncertain execution because they are defined under
5 tests that evaluate false.
6
7 Don't identify a node if there is a collectively exhaustive set of paths
8 that define the name, raise, or return (e.g. every if/else branch).
9 """
10 uncertain_nodes = []
11 for other_node in found_nodes:
12 if in_type_checking_block(other_node):
13 continue
14
15 if not isinstance(other_node, nodes.AssignName):
16 continue
17
18 closest_if = utils.get_node_first_ancestor_of_type(other_node, nodes.If)
19 if closest_if is None:
20 continue
21 if node.frame() is not closest_if.frame():
22 continue
23 if closest_if is not None and closest_if.parent_of(node):
24 continue
25
26 # Name defined in every if/else branch
27 if NamesConsumer._exhaustively_define_name_raise_or_return(
28 other_node.name, closest_if
29 ):
30 continue
31
32 # Higher-level if already determined to be always false
33 if any(
34 if_node.parent_of(closest_if)
35 for if_node in self._if_nodes_deemed_uncertain
36 ):
37 uncertain_nodes.append(other_node)
38 continue
39
40 # All inferred values must test false
41 if isinstance(closest_if.test, nodes.NamedExpr):
42 test = closest_if.test.value
43 else:
44 test = closest_if.test
45 all_inferred = utils.infer_all(test)
46 if not all_inferred or not all(
47 isinstance(inferred, nodes.Const) and not inferred.value
48 for inferred in all_inferred
49 ):
50 continue
51
52 uncertain_nodes.append(other_node)
53 self._if_nodes_deemed_uncertain.add(closest_if)
54
55 return uncertain_nodes
Path 18: 2 calls (0.0)
list (2)
Name (2)
[] (2)
1def _uncertain_nodes_in_false_tests(
2 self, found_nodes: list[nodes.NodeNG], node: nodes.NodeNG
3 ) -> list[nodes.NodeNG]:
4 """Identify nodes of uncertain execution because they are defined under
5 tests that evaluate false.
6
7 Don't identify a node if there is a collectively exhaustive set of paths
8 that define the name, raise, or return (e.g. every if/else branch).
9 """
10 uncertain_nodes = []
11 for other_node in found_nodes:
12 if in_type_checking_block(other_node):
13 continue
14
15 if not isinstance(other_node, nodes.AssignName):
16 continue
17
18 closest_if = utils.get_node_first_ancestor_of_type(other_node, nodes.If)
19 if closest_if is None:
20 continue
21 if node.frame() is not closest_if.frame():
22 continue
23 if closest_if is not None and closest_if.parent_of(node):
24 continue
25
26 # Name defined in every if/else branch
27 if NamesConsumer._exhaustively_define_name_raise_or_return(
28 other_node.name, closest_if
29 ):
30 continue
31
32 # Higher-level if already determined to be always false
33 if any(
34 if_node.parent_of(closest_if)
35 for if_node in self._if_nodes_deemed_uncertain
36 ):
37 uncertain_nodes.append(other_node)
38 continue
39
40 # All inferred values must test false
41 if isinstance(closest_if.test, nodes.NamedExpr):
42 test = closest_if.test.value
43 else:
44 test = closest_if.test
45 all_inferred = utils.infer_all(test)
46 if not all_inferred or not all(
47 isinstance(inferred, nodes.Const) and not inferred.value
48 for inferred in all_inferred
49 ):
50 continue
51
52 uncertain_nodes.append(other_node)
53 self._if_nodes_deemed_uncertain.add(closest_if)
54
55 return uncertain_nodes
Path 19: 1 calls (0.0)
list (1)
Name (1)
[] (1)
GeneratorExit (1)
1def _uncertain_nodes_in_false_tests(
2 self, found_nodes: list[nodes.NodeNG], node: nodes.NodeNG
3 ) -> list[nodes.NodeNG]:
4 """Identify nodes of uncertain execution because they are defined under
5 tests that evaluate false.
6
7 Don't identify a node if there is a collectively exhaustive set of paths
8 that define the name, raise, or return (e.g. every if/else branch).
9 """
10 uncertain_nodes = []
11 for other_node in found_nodes:
12 if in_type_checking_block(other_node):
13 continue
14
15 if not isinstance(other_node, nodes.AssignName):
16 continue
17
18 closest_if = utils.get_node_first_ancestor_of_type(other_node, nodes.If)
19 if closest_if is None:
20 continue
21 if node.frame() is not closest_if.frame():
22 continue
23 if closest_if is not None and closest_if.parent_of(node):
24 continue
25
26 # Name defined in every if/else branch
27 if NamesConsumer._exhaustively_define_name_raise_or_return(
28 other_node.name, closest_if
29 ):
30 continue
31
32 # Higher-level if already determined to be always false
33 if any(
34 if_node.parent_of(closest_if)
35 for if_node in self._if_nodes_deemed_uncertain
36 ):
37 uncertain_nodes.append(other_node)
38 continue
39
40 # All inferred values must test false
41 if isinstance(closest_if.test, nodes.NamedExpr):
42 test = closest_if.test.value
43 else:
44 test = closest_if.test
45 all_inferred = utils.infer_all(test)
46 if not all_inferred or not all(
47 isinstance(inferred, nodes.Const) and not inferred.value
48 for inferred in all_inferred
49 ):
50 continue
51
52 uncertain_nodes.append(other_node)
53 self._if_nodes_deemed_uncertain.add(closest_if)
54
55 return uncertain_nodes
Path 20: 1 calls (0.0)
list (1)
Name (1)
list (1)
GeneratorExit (1)
1def _uncertain_nodes_in_false_tests(
2 self, found_nodes: list[nodes.NodeNG], node: nodes.NodeNG
3 ) -> list[nodes.NodeNG]:
4 """Identify nodes of uncertain execution because they are defined under
5 tests that evaluate false.
6
7 Don't identify a node if there is a collectively exhaustive set of paths
8 that define the name, raise, or return (e.g. every if/else branch).
9 """
10 uncertain_nodes = []
11 for other_node in found_nodes:
12 if in_type_checking_block(other_node):
13 continue
14
15 if not isinstance(other_node, nodes.AssignName):
16 continue
17
18 closest_if = utils.get_node_first_ancestor_of_type(other_node, nodes.If)
19 if closest_if is None:
20 continue
21 if node.frame() is not closest_if.frame():
22 continue
23 if closest_if is not None and closest_if.parent_of(node):
24 continue
25
26 # Name defined in every if/else branch
27 if NamesConsumer._exhaustively_define_name_raise_or_return(
28 other_node.name, closest_if
29 ):
30 continue
31
32 # Higher-level if already determined to be always false
33 if any(
34 if_node.parent_of(closest_if)
35 for if_node in self._if_nodes_deemed_uncertain
36 ):
37 uncertain_nodes.append(other_node)
38 continue
39
40 # All inferred values must test false
41 if isinstance(closest_if.test, nodes.NamedExpr):
42 test = closest_if.test.value
43 else:
44 test = closest_if.test
45 all_inferred = utils.infer_all(test)
46 if not all_inferred or not all(
47 isinstance(inferred, nodes.Const) and not inferred.value
48 for inferred in all_inferred
49 ):
50 continue
51
52 uncertain_nodes.append(other_node)
53 self._if_nodes_deemed_uncertain.add(closest_if)
54
55 return uncertain_nodes
Path 21: 1 calls (0.0)
list (1)
Name (1)
[] (1)
1def _uncertain_nodes_in_false_tests(
2 self, found_nodes: list[nodes.NodeNG], node: nodes.NodeNG
3 ) -> list[nodes.NodeNG]:
4 """Identify nodes of uncertain execution because they are defined under
5 tests that evaluate false.
6
7 Don't identify a node if there is a collectively exhaustive set of paths
8 that define the name, raise, or return (e.g. every if/else branch).
9 """
10 uncertain_nodes = []
11 for other_node in found_nodes:
12 if in_type_checking_block(other_node):
13 continue
14
15 if not isinstance(other_node, nodes.AssignName):
16 continue
17
18 closest_if = utils.get_node_first_ancestor_of_type(other_node, nodes.If)
19 if closest_if is None:
20 continue
21 if node.frame() is not closest_if.frame():
22 continue
23 if closest_if is not None and closest_if.parent_of(node):
24 continue
25
26 # Name defined in every if/else branch
27 if NamesConsumer._exhaustively_define_name_raise_or_return(
28 other_node.name, closest_if
29 ):
30 continue
31
32 # Higher-level if already determined to be always false
33 if any(
34 if_node.parent_of(closest_if)
35 for if_node in self._if_nodes_deemed_uncertain
36 ):
37 uncertain_nodes.append(other_node)
38 continue
39
40 # All inferred values must test false
41 if isinstance(closest_if.test, nodes.NamedExpr):
42 test = closest_if.test.value
43 else:
44 test = closest_if.test
45 all_inferred = utils.infer_all(test)
46 if not all_inferred or not all(
47 isinstance(inferred, nodes.Const) and not inferred.value
48 for inferred in all_inferred
49 ):
50 continue
51
52 uncertain_nodes.append(other_node)
53 self._if_nodes_deemed_uncertain.add(closest_if)
54
55 return uncertain_nodes
Path 22: 1 calls (0.0)
list (1)
Name (1)
list (1)
1def _uncertain_nodes_in_false_tests(
2 self, found_nodes: list[nodes.NodeNG], node: nodes.NodeNG
3 ) -> list[nodes.NodeNG]:
4 """Identify nodes of uncertain execution because they are defined under
5 tests that evaluate false.
6
7 Don't identify a node if there is a collectively exhaustive set of paths
8 that define the name, raise, or return (e.g. every if/else branch).
9 """
10 uncertain_nodes = []
11 for other_node in found_nodes:
12 if in_type_checking_block(other_node):
13 continue
14
15 if not isinstance(other_node, nodes.AssignName):
16 continue
17
18 closest_if = utils.get_node_first_ancestor_of_type(other_node, nodes.If)
19 if closest_if is None:
20 continue
21 if node.frame() is not closest_if.frame():
22 continue
23 if closest_if is not None and closest_if.parent_of(node):
24 continue
25
26 # Name defined in every if/else branch
27 if NamesConsumer._exhaustively_define_name_raise_or_return(
28 other_node.name, closest_if
29 ):
30 continue
31
32 # Higher-level if already determined to be always false
33 if any(
34 if_node.parent_of(closest_if)
35 for if_node in self._if_nodes_deemed_uncertain
36 ):
37 uncertain_nodes.append(other_node)
38 continue
39
40 # All inferred values must test false
41 if isinstance(closest_if.test, nodes.NamedExpr):
42 test = closest_if.test.value
43 else:
44 test = closest_if.test
45 all_inferred = utils.infer_all(test)
46 if not all_inferred or not all(
47 isinstance(inferred, nodes.Const) and not inferred.value
48 for inferred in all_inferred
49 ):
50 continue
51
52 uncertain_nodes.append(other_node)
53 self._if_nodes_deemed_uncertain.add(closest_if)
54
55 return uncertain_nodes
Path 23: 1 calls (0.0)
list (1)
Name (1)
list (1)
GeneratorExit (1)
1def _uncertain_nodes_in_false_tests(
2 self, found_nodes: list[nodes.NodeNG], node: nodes.NodeNG
3 ) -> list[nodes.NodeNG]:
4 """Identify nodes of uncertain execution because they are defined under
5 tests that evaluate false.
6
7 Don't identify a node if there is a collectively exhaustive set of paths
8 that define the name, raise, or return (e.g. every if/else branch).
9 """
10 uncertain_nodes = []
11 for other_node in found_nodes:
12 if in_type_checking_block(other_node):
13 continue
14
15 if not isinstance(other_node, nodes.AssignName):
16 continue
17
18 closest_if = utils.get_node_first_ancestor_of_type(other_node, nodes.If)
19 if closest_if is None:
20 continue
21 if node.frame() is not closest_if.frame():
22 continue
23 if closest_if is not None and closest_if.parent_of(node):
24 continue
25
26 # Name defined in every if/else branch
27 if NamesConsumer._exhaustively_define_name_raise_or_return(
28 other_node.name, closest_if
29 ):
30 continue
31
32 # Higher-level if already determined to be always false
33 if any(
34 if_node.parent_of(closest_if)
35 for if_node in self._if_nodes_deemed_uncertain
36 ):
37 uncertain_nodes.append(other_node)
38 continue
39
40 # All inferred values must test false
41 if isinstance(closest_if.test, nodes.NamedExpr):
42 test = closest_if.test.value
43 else:
44 test = closest_if.test
45 all_inferred = utils.infer_all(test)
46 if not all_inferred or not all(
47 isinstance(inferred, nodes.Const) and not inferred.value
48 for inferred in all_inferred
49 ):
50 continue
51
52 uncertain_nodes.append(other_node)
53 self._if_nodes_deemed_uncertain.add(closest_if)
54
55 return uncertain_nodes
Path 24: 1 calls (0.0)
list (1)
Name (1)
list (1)
1def _uncertain_nodes_in_false_tests(
2 self, found_nodes: list[nodes.NodeNG], node: nodes.NodeNG
3 ) -> list[nodes.NodeNG]:
4 """Identify nodes of uncertain execution because they are defined under
5 tests that evaluate false.
6
7 Don't identify a node if there is a collectively exhaustive set of paths
8 that define the name, raise, or return (e.g. every if/else branch).
9 """
10 uncertain_nodes = []
11 for other_node in found_nodes:
12 if in_type_checking_block(other_node):
13 continue
14
15 if not isinstance(other_node, nodes.AssignName):
16 continue
17
18 closest_if = utils.get_node_first_ancestor_of_type(other_node, nodes.If)
19 if closest_if is None:
20 continue
21 if node.frame() is not closest_if.frame():
22 continue
23 if closest_if is not None and closest_if.parent_of(node):
24 continue
25
26 # Name defined in every if/else branch
27 if NamesConsumer._exhaustively_define_name_raise_or_return(
28 other_node.name, closest_if
29 ):
30 continue
31
32 # Higher-level if already determined to be always false
33 if any(
34 if_node.parent_of(closest_if)
35 for if_node in self._if_nodes_deemed_uncertain
36 ):
37 uncertain_nodes.append(other_node)
38 continue
39
40 # All inferred values must test false
41 if isinstance(closest_if.test, nodes.NamedExpr):
42 test = closest_if.test.value
43 else:
44 test = closest_if.test
45 all_inferred = utils.infer_all(test)
46 if not all_inferred or not all(
47 isinstance(inferred, nodes.Const) and not inferred.value
48 for inferred in all_inferred
49 ):
50 continue
51
52 uncertain_nodes.append(other_node)
53 self._if_nodes_deemed_uncertain.add(closest_if)
54
55 return uncertain_nodes