summaryrefslogtreecommitdiff
path: root/checkers/variables.py
diff options
context:
space:
mode:
authorEmile Anclin <emile.anclin@logilab.fr>2010-11-04 17:39:26 +0100
committerEmile Anclin <emile.anclin@logilab.fr>2010-11-04 17:39:26 +0100
commit45b8973011bca999ea3f16171e7a5621abd20439 (patch)
treec87217a9816998f18a54b4f5953e3503142e8464 /checkers/variables.py
parent9c423729b77fc3d344cec7c39fb864eaac438984 (diff)
downloadpylint-45b8973011bca999ea3f16171e7a5621abd20439.tar.gz
py3k: list comprehension is now a scoped node
Diffstat (limited to 'checkers/variables.py')
-rw-r--r--checkers/variables.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/checkers/variables.py b/checkers/variables.py
index 1e73a60..d9fd331 100644
--- a/checkers/variables.py
+++ b/checkers/variables.py
@@ -512,6 +512,24 @@ builtins. Remember that you should avoid to define new builtins when possible.'
return None
+class VariablesChecker3k(VariablesChecker):
+ '''Modified variables checker for 3k'''
+ # listcomp have now also their scope
+
+ def visit_listcomp(self, node):
+ """visit dictcomp: update consumption analysis variable
+ """
+ self._to_consume.append((copy(node.locals), {}, 'comprehension'))
+
+ def leave_listcomp(self, _):
+ """leave dictcomp: update consumption analysis variable
+ """
+ # do not check for not used locals here
+ self._to_consume.pop()
+
+import sys
+if sys.version_info >= (3, 0):
+ VariablesChecker = VariablesChecker3k
def register(linter):