summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Th?nault <sylvain.thenault@logilab.fr>2009-11-25 19:36:56 +0100
committerSylvain Th?nault <sylvain.thenault@logilab.fr>2009-11-25 19:36:56 +0100
commit8964a88b0810132c718e6760928ee66c05d8bd61 (patch)
tree798e3fa8bbb076ca656b2f3149d8e3ad37dc2e93
parent965ff2408eb111532b1babfcd0b71724ce5f1202 (diff)
downloadpylint-8964a88b0810132c718e6760928ee66c05d8bd61.tar.gz
fix #18862: E0601 false positive with lambda functions
-rw-r--r--ChangeLog1
-rw-r--r--checkers/variables.py3
-rw-r--r--test/input/func_noerror_lambda_use_before_assign.py7
3 files changed, 10 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index d84bd2c..c5ce38e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,7 @@ ChangeLog for PyLint
* include James Lingar patches for function call arguments checker
* improved flymake code and doc provided by Derek Harland
* refactor & fix the imports checker
+ * fix #18862: E0601 false positive with lambda functions
* fix #8764: More than one statement on a single line false positive with
try/except/finally
* Nathaniel's fix for w0108 false positive
diff --git a/checkers/variables.py b/checkers/variables.py
index 454fc9c..f17c940 100644
--- a/checkers/variables.py
+++ b/checkers/variables.py
@@ -380,7 +380,8 @@ builtins. Remember that you should avoid to define new builtins when possible.'
if defstmt is stmt and isinstance(node, (astng.DelName,
astng.AssName)):
self.add_message('E0602', args=name, node=node)
- else:
+ elif self._to_consume[-1][-1] != 'lambda':
+ # E0601 may *not* occurs in lambda scope
self.add_message('E0601', args=name, node=node)
if not isinstance(node, astng.AssName): # Aug AssName
del to_consume[name]
diff --git a/test/input/func_noerror_lambda_use_before_assign.py b/test/input/func_noerror_lambda_use_before_assign.py
new file mode 100644
index 0000000..0ab8c2c
--- /dev/null
+++ b/test/input/func_noerror_lambda_use_before_assign.py
@@ -0,0 +1,7 @@
+"""https://www.logilab.net/elo/ticket/18862"""
+__revision__ = 1
+def function():
+ """hop"""
+ ggg = lambda: xxx
+ xxx = 1
+ print ggg()