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
commit1a9bcaada90a50d82796e2617871f88aed90722a (patch)
tree3a95262098fab9067ab411f6c54f54aad875457f
parentf165a6675322f60d39e6c5e2902c478311232318 (diff)
downloadpylint-git-1a9bcaada90a50d82796e2617871f88aed90722a.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 d84bd2cfd..c5ce38e7a 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 454fc9c63..f17c94033 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 000000000..0ab8c2c33
--- /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()