summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2015-09-21 13:59:48 +0000
committerClaudiu Popa <pcmanticore@gmail.com>2015-09-21 13:59:48 +0000
commit7d30cdb9be39d089806aece9be2e8a3545482a5a (patch)
tree4179930516007577a0f0f915f1a3b3786f6332ec
parentb2de6be25d76043bbff9dd3ae77f2ca8f0e24f49 (diff)
downloadpylint-7d30cdb9be39d089806aece9be2e8a3545482a5a.tar.gz
Add changelog entry for 014f596 and a couple of other fixes.
-rw-r--r--CONTRIBUTORS.txt2
-rw-r--r--ChangeLog5
-rw-r--r--pylint/checkers/base.py6
-rw-r--r--pylint/test/functional/nonlocal_without_binding.py4
4 files changed, 13 insertions, 4 deletions
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
index e88762a..518a7a0 100644
--- a/CONTRIBUTORS.txt
+++ b/CONTRIBUTORS.txt
@@ -68,3 +68,5 @@ Order doesn't matter (not that much, at least ;)
by their feedback or even patches, if I've forgotten you, send me a note !
* Cezar Elnazli: deprecated-method
+
+* Stéphane Wirtel: nonlocal-without-binding
diff --git a/ChangeLog b/ChangeLog
index f209bda..8154628 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -295,6 +295,11 @@ ChangeLog for Pylint
for --load-plugins never actually worked, while it also didn't raise
an error. Closes issue #424.
+ * Add a new error, 'nonlocal-without-binding'
+
+ The error is emitted on Python 3 when a nonlocal name is not bound
+ to any variable in the parents scopes. Closes issue #582.
+
2015-03-14 -- 1.4.3
diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py
index 38cf0ab..70fa2e1 100644
--- a/pylint/checkers/base.py
+++ b/pylint/checkers/base.py
@@ -330,7 +330,8 @@ class BasicErrorChecker(_BasicChecker):
'inside a finally clause, which is a SyntaxError.'),
'E0117': ("nonlocal variable without binding",
'nonlocal-without-binding',
- 'Emitted when a nonlocal variable is not bound',
+ 'Emitted when a nonlocal variable does not have an attached '
+ 'name somewhere in the parent scopes',
{'minversion': (3, 0)}),
}
@@ -464,12 +465,13 @@ class BasicErrorChecker(_BasicChecker):
if not isinstance(current_scope, astroid.FunctionDef):
self.add_message('nonlocal-without-binding', node=node)
- break
+ return
else:
if name not in current_scope.locals:
current_scope = current_scope.parent.scope()
continue
else:
+ # Okay, found it.
return
self.add_message('nonlocal-without-binding', node=node)
diff --git a/pylint/test/functional/nonlocal_without_binding.py b/pylint/test/functional/nonlocal_without_binding.py
index 2871ed6..16cfd14 100644
--- a/pylint/test/functional/nonlocal_without_binding.py
+++ b/pylint/test/functional/nonlocal_without_binding.py
@@ -1,6 +1,6 @@
""" Checks that reversed() receive proper argument """
-# pylint: disable=missing-docstring
-# pylint: disable=too-few-public-methods,no-self-use,no-absolute-import,invalid-name,unused-variable
+# pylint: disable=missing-docstring,invalid-name,unused-variable
+# pylint: disable=too-few-public-methods,no-self-use,no-absolute-import
def test():
def parent():