summaryrefslogtreecommitdiff
path: root/pylint/checkers/modified_iterating_checker.py
diff options
context:
space:
mode:
authororSolocate <38433858+orSolocate@users.noreply.github.com>2022-03-26 15:47:26 +0300
committerGitHub <noreply@github.com>2022-03-26 13:47:26 +0100
commit5f33ca225756882589e2965703cae03e2860051a (patch)
treea6d593ea2eda00681f3b443a16c8f649a35253d2 /pylint/checkers/modified_iterating_checker.py
parent5d21f4235fec4833d10e09870cbe4134d565f3d5 (diff)
downloadpylint-git-5f33ca225756882589e2965703cae03e2860051a.tar.gz
Fix issue #5969 for `modified_iterating-list` (#5986)
When the list/dict/set being iterated through is a function call. Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Diffstat (limited to 'pylint/checkers/modified_iterating_checker.py')
-rw-r--r--pylint/checkers/modified_iterating_checker.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/pylint/checkers/modified_iterating_checker.py b/pylint/checkers/modified_iterating_checker.py
index d1fe08d40..ca2a0c900 100644
--- a/pylint/checkers/modified_iterating_checker.py
+++ b/pylint/checkers/modified_iterating_checker.py
@@ -57,8 +57,9 @@ class ModifiedIterationChecker(checkers.BaseChecker):
)
def visit_for(self, node: nodes.For) -> None:
iter_obj = node.iter
- for body_node in node.body:
- self._modified_iterating_check_on_node_and_children(body_node, iter_obj)
+ if isinstance(iter_obj, nodes.Name):
+ for body_node in node.body:
+ self._modified_iterating_check_on_node_and_children(body_node, iter_obj)
def _modified_iterating_check_on_node_and_children(
self, body_node: nodes.NodeNG, iter_obj: nodes.NodeNG