summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--pylint/checkers/utils.py1
-rw-r--r--pylint/test/unittest_checker_variables.py13
3 files changed, 17 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 562ec2c9f..bec8831fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -23,6 +23,10 @@ Release date: |TBA|
Close #1169
+ * Fix false-postive undefined-variable in nested lambda
+
+ Close #760
+
What's New in Pylint 1.9.3?
===========================
diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py
index 36f6e862c..ef6269e93 100644
--- a/pylint/checkers/utils.py
+++ b/pylint/checkers/utils.py
@@ -239,7 +239,6 @@ def is_defined_before(var_node):
return True
if getattr(_node, 'name', None) == varname:
return True
- break
elif isinstance(_node, astroid.ExceptHandler):
if isinstance(_node.name, astroid.AssignName):
ass_node = _node.name
diff --git a/pylint/test/unittest_checker_variables.py b/pylint/test/unittest_checker_variables.py
index 9bfabbba4..5e919d08d 100644
--- a/pylint/test/unittest_checker_variables.py
+++ b/pylint/test/unittest_checker_variables.py
@@ -180,6 +180,7 @@ class TestVariablesCheckerWithTearDown(CheckerTestCase):
with self.assertNoMessages():
self.walk(node)
+
def test_scope_in_defaults(self):
# Should not emit undefined variable
node = astroid.extract_node('''
@@ -201,6 +202,18 @@ class TestVariablesCheckerWithTearDown(CheckerTestCase):
with self.assertNoMessages():
self.walk(node)
+ def test_nested_lambda(self):
+ """Make sure variables from parent lambdas
+ aren't noted as undefined
+
+ https://github.com/PyCQA/pylint/issues/760
+ """
+ node = astroid.parse('''
+ lambda x: lambda: x + 1
+ ''')
+ with self.assertNoMessages():
+ self.walk(node)
+
class TestMissingSubmodule(CheckerTestCase):
CHECKER_CLASS = variables.VariablesChecker