Method: pylint.checkers.variables.VariablesChecker._check_unpacking
Calls: 115, Exceptions: 0, Paths: 7Back
Path 1: 61 calls (0.53)
Tuple (47) List (9) Instance (2) Dict (2) DictItems (1)
Assign (61)
list (61)
1def _check_unpacking(
2 self, inferred: InferenceResult, node: nodes.Assign, targets: list[nodes.NodeNG]
3 ) -> None:
4 """Check for unbalanced tuple unpacking
5 and unpacking non sequences.
6 """
7 if utils.is_inside_abstract_class(node):
8 return
9 if utils.is_comprehension(node):
10 return
11 if inferred is astroid.Uninferable:
12 return
13 if (
14 isinstance(inferred.parent, nodes.Arguments)
15 and isinstance(node.value, nodes.Name)
16 and node.value.name == inferred.parent.vararg
17 ):
18 # Variable-length argument, we can't determine the length.
19 return
20
21 # Attempt to check unpacking is properly balanced
22 values = self._nodes_to_unpack(inferred)
23 details = _get_unpacking_extra_info(node, inferred)
24
25 if values is not None:
26 if len(targets) != len(values):
27 self._report_unbalanced_unpacking(
28 node, inferred, targets, values, details
29 )
30 # attempt to check unpacking may be possible (i.e. RHS is iterable)
31 elif not utils.is_iterable(inferred):
32 self._report_unpacking_non_sequence(node, details)
Path 2: 21 calls (0.18)
Tuple (8) List (3) DictItems (3) DictValues (2) Dict (2) Instance (2) DictKeys (1)
Assign (21)
list (21)
1def _check_unpacking(
2 self, inferred: InferenceResult, node: nodes.Assign, targets: list[nodes.NodeNG]
3 ) -> None:
4 """Check for unbalanced tuple unpacking
5 and unpacking non sequences.
6 """
7 if utils.is_inside_abstract_class(node):
8 return
9 if utils.is_comprehension(node):
10 return
11 if inferred is astroid.Uninferable:
12 return
13 if (
14 isinstance(inferred.parent, nodes.Arguments)
15 and isinstance(node.value, nodes.Name)
16 and node.value.name == inferred.parent.vararg
17 ):
18 # Variable-length argument, we can't determine the length.
19 return
20
21 # Attempt to check unpacking is properly balanced
22 values = self._nodes_to_unpack(inferred)
23 details = _get_unpacking_extra_info(node, inferred)
24
25 if values is not None:
26 if len(targets) != len(values):
27 self._report_unbalanced_unpacking(
28 node, inferred, targets, values, details
29 )
30 # attempt to check unpacking may be possible (i.e. RHS is iterable)
31 elif not utils.is_iterable(inferred):
32 self._report_unpacking_non_sequence(node, details)
Path 3: 12 calls (0.1)
Const (4) Instance (3) FunctionDef (3) ClassDef (2)
Assign (12)
list (12)
1def _check_unpacking(
2 self, inferred: InferenceResult, node: nodes.Assign, targets: list[nodes.NodeNG]
3 ) -> None:
4 """Check for unbalanced tuple unpacking
5 and unpacking non sequences.
6 """
7 if utils.is_inside_abstract_class(node):
8 return
9 if utils.is_comprehension(node):
10 return
11 if inferred is astroid.Uninferable:
12 return
13 if (
14 isinstance(inferred.parent, nodes.Arguments)
15 and isinstance(node.value, nodes.Name)
16 and node.value.name == inferred.parent.vararg
17 ):
18 # Variable-length argument, we can't determine the length.
19 return
20
21 # Attempt to check unpacking is properly balanced
22 values = self._nodes_to_unpack(inferred)
23 details = _get_unpacking_extra_info(node, inferred)
24
25 if values is not None:
26 if len(targets) != len(values):
27 self._report_unbalanced_unpacking(
28 node, inferred, targets, values, details
29 )
30 # attempt to check unpacking may be possible (i.e. RHS is iterable)
31 elif not utils.is_iterable(inferred):
32 self._report_unpacking_non_sequence(node, details)
Path 4: 11 calls (0.1)
Instance (5) Const (4) Set (1) ClassDef (1)
Assign (11)
list (11)
1def _check_unpacking(
2 self, inferred: InferenceResult, node: nodes.Assign, targets: list[nodes.NodeNG]
3 ) -> None:
4 """Check for unbalanced tuple unpacking
5 and unpacking non sequences.
6 """
7 if utils.is_inside_abstract_class(node):
8 return
9 if utils.is_comprehension(node):
10 return
11 if inferred is astroid.Uninferable:
12 return
13 if (
14 isinstance(inferred.parent, nodes.Arguments)
15 and isinstance(node.value, nodes.Name)
16 and node.value.name == inferred.parent.vararg
17 ):
18 # Variable-length argument, we can't determine the length.
19 return
20
21 # Attempt to check unpacking is properly balanced
22 values = self._nodes_to_unpack(inferred)
23 details = _get_unpacking_extra_info(node, inferred)
24
25 if values is not None:
26 if len(targets) != len(values):
27 self._report_unbalanced_unpacking(
28 node, inferred, targets, values, details
29 )
30 # attempt to check unpacking may be possible (i.e. RHS is iterable)
31 elif not utils.is_iterable(inferred):
32 self._report_unpacking_non_sequence(node, details)
Path 5: 8 calls (0.07)
Uninferable (8)
Assign (8)
list (8)
None (8)
1def _check_unpacking(
2 self, inferred: InferenceResult, node: nodes.Assign, targets: list[nodes.NodeNG]
3 ) -> None:
4 """Check for unbalanced tuple unpacking
5 and unpacking non sequences.
6 """
7 if utils.is_inside_abstract_class(node):
8 return
9 if utils.is_comprehension(node):
10 return
11 if inferred is astroid.Uninferable:
12 return
13 if (
14 isinstance(inferred.parent, nodes.Arguments)
15 and isinstance(node.value, nodes.Name)
16 and node.value.name == inferred.parent.vararg
17 ):
18 # Variable-length argument, we can't determine the length.
19 return
20
21 # Attempt to check unpacking is properly balanced
22 values = self._nodes_to_unpack(inferred)
23 details = _get_unpacking_extra_info(node, inferred)
24
25 if values is not None:
26 if len(targets) != len(values):
27 self._report_unbalanced_unpacking(
28 node, inferred, targets, values, details
29 )
30 # attempt to check unpacking may be possible (i.e. RHS is iterable)
31 elif not utils.is_iterable(inferred):
32 self._report_unpacking_non_sequence(node, details)
Path 6: 1 calls (0.01)
Tuple (1)
Assign (1)
list (1)
None (1)
1def _check_unpacking(
2 self, inferred: InferenceResult, node: nodes.Assign, targets: list[nodes.NodeNG]
3 ) -> None:
4 """Check for unbalanced tuple unpacking
5 and unpacking non sequences.
6 """
7 if utils.is_inside_abstract_class(node):
8 return
9 if utils.is_comprehension(node):
10 return
11 if inferred is astroid.Uninferable:
12 return
13 if (
14 isinstance(inferred.parent, nodes.Arguments)
15 and isinstance(node.value, nodes.Name)
16 and node.value.name == inferred.parent.vararg
17 ):
18 # Variable-length argument, we can't determine the length.
19 return
20
21 # Attempt to check unpacking is properly balanced
22 values = self._nodes_to_unpack(inferred)
23 details = _get_unpacking_extra_info(node, inferred)
24
25 if values is not None:
26 if len(targets) != len(values):
27 self._report_unbalanced_unpacking(
28 node, inferred, targets, values, details
29 )
30 # attempt to check unpacking may be possible (i.e. RHS is iterable)
31 elif not utils.is_iterable(inferred):
32 self._report_unpacking_non_sequence(node, details)
Path 7: 1 calls (0.01)
Const (1)
Assign (1)
list (1)
None (1)
1def _check_unpacking(
2 self, inferred: InferenceResult, node: nodes.Assign, targets: list[nodes.NodeNG]
3 ) -> None:
4 """Check for unbalanced tuple unpacking
5 and unpacking non sequences.
6 """
7 if utils.is_inside_abstract_class(node):
8 return
9 if utils.is_comprehension(node):
10 return
11 if inferred is astroid.Uninferable:
12 return
13 if (
14 isinstance(inferred.parent, nodes.Arguments)
15 and isinstance(node.value, nodes.Name)
16 and node.value.name == inferred.parent.vararg
17 ):
18 # Variable-length argument, we can't determine the length.
19 return
20
21 # Attempt to check unpacking is properly balanced
22 values = self._nodes_to_unpack(inferred)
23 details = _get_unpacking_extra_info(node, inferred)
24
25 if values is not None:
26 if len(targets) != len(values):
27 self._report_unbalanced_unpacking(
28 node, inferred, targets, values, details
29 )
30 # attempt to check unpacking may be possible (i.e. RHS is iterable)
31 elif not utils.is_iterable(inferred):
32 self._report_unpacking_non_sequence(node, details)