summaryrefslogtreecommitdiff
path: root/pylint/checkers/utils.py
diff options
context:
space:
mode:
authorDani Alcala <112832187+clavedeluna@users.noreply.github.com>2022-12-26 11:37:58 -0300
committerGitHub <noreply@github.com>2022-12-26 09:37:58 -0500
commitcf5ea8a32bcdac0bd889f973272c59599b40af95 (patch)
treeac3058df77058dc35e0478be4af3a78e9cdf90d2 /pylint/checkers/utils.py
parentc35f5a61f3d842709cf48e708bcff442e4864354 (diff)
downloadpylint-git-cf5ea8a32bcdac0bd889f973272c59599b40af95.tar.gz
Fix `use-sequence-for-iteration` when unpacking a set with `*` (#7975)
Diffstat (limited to 'pylint/checkers/utils.py')
-rw-r--r--pylint/checkers/utils.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py
index 98e7cbfe3..95778dbad 100644
--- a/pylint/checkers/utils.py
+++ b/pylint/checkers/utils.py
@@ -2030,6 +2030,20 @@ def find_assigned_names_recursive(
yield from find_assigned_names_recursive(elt)
+def has_starred_node_recursive(
+ node: nodes.For | nodes.Comprehension | nodes.Set,
+) -> Iterator[bool]:
+ """Yield ``True`` if a Starred node is found recursively."""
+ if isinstance(node, nodes.Starred):
+ yield True
+ elif isinstance(node, nodes.Set):
+ for elt in node.elts:
+ yield from has_starred_node_recursive(elt)
+ elif isinstance(node, (nodes.For, nodes.Comprehension)):
+ for elt in node.iter.elts:
+ yield from has_starred_node_recursive(elt)
+
+
def is_hashable(node: nodes.NodeNG) -> bool:
"""Return whether any inferred value of `node` is hashable.