summaryrefslogtreecommitdiff
path: root/pylint/checkers/python3.py
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2018-05-24 09:00:28 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2018-05-24 09:00:50 +0200
commit009c1a71d0bdd70d24e07179b07b20bc7df59b39 (patch)
treed5cc0cace2271ddfa2e843a09af2272f99d8a198 /pylint/checkers/python3.py
parent37e6384b5f451a737794e41e11a11d561dfc83aa (diff)
downloadpylint-git-009c1a71d0bdd70d24e07179b07b20bc7df59b39.tar.gz
Make sure the value is not defined in the same comprehension when looking for comprehension-escape values. Close #2106
Diffstat (limited to 'pylint/checkers/python3.py')
-rw-r--r--pylint/checkers/python3.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/pylint/checkers/python3.py b/pylint/checkers/python3.py
index d8215f1f3..7c7f5c896 100644
--- a/pylint/checkers/python3.py
+++ b/pylint/checkers/python3.py
@@ -649,10 +649,17 @@ class Python3Checker(checkers.BaseChecker):
)
if has_redefined_assign_name:
return
+
+ emitted_for_names = set()
scope_names = list(scope_names)
for scope_name in scope_names:
- if scope_name.name not in names or scope_name.lineno <= node.lineno:
+ if (scope_name.name not in names
+ or scope_name.lineno <= node.lineno
+ or scope_name.name in emitted_for_names
+ or scope_name.scope() == node):
continue
+
+ emitted_for_names.add(scope_name.name)
self.add_message('comprehension-escape', node=scope_name)
def visit_name(self, node):