summaryrefslogtreecommitdiff
path: root/pylint/checkers/variables.py
diff options
context:
space:
mode:
authorClaudiu Popa <cpopa@cloudbasesolutions.com>2015-04-16 13:40:00 +0300
committerClaudiu Popa <cpopa@cloudbasesolutions.com>2015-04-16 13:40:00 +0300
commit3aeab3a1de09763cc749bc239d71cf6b81616530 (patch)
treeb6fbc5e5c5b07f1f1fce05ed01acf2c454a08265 /pylint/checkers/variables.py
parent0c1818005e9b07b304a7c5933abc58e7b81f9078 (diff)
downloadpylint-3aeab3a1de09763cc749bc239d71cf6b81616530.tar.gz
Don't emit redefined-outer-name for __future__ directives.
Closes issue #520.
Diffstat (limited to 'pylint/checkers/variables.py')
-rw-r--r--pylint/checkers/variables.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py
index c813727..f4fc853 100644
--- a/pylint/checkers/variables.py
+++ b/pylint/checkers/variables.py
@@ -35,7 +35,7 @@ from pylint.checkers.utils import (
import six
SPECIAL_OBJ = re.compile("^_{2}[a-z]+_{2}$")
-
+FUTURE = '__future__'
PY3K = sys.version_info >= (3, 0)
@@ -516,10 +516,17 @@ builtins. Remember that you should avoid to define new builtins when possible.'
if is_inside_except(stmt):
continue
if name in globs and not isinstance(stmt, astroid.Global):
- line = globs[name][0].fromlineno
+ definition = globs[name][0]
+ if (isinstance(definition, astroid.From)
+ and definition.modname == FUTURE):
+ # It is a __future__ directive, not a symbol.
+ continue
+
+ line = definition.fromlineno
dummy_rgx = self.config.dummy_variables_rgx
- if not dummy_rgx.match(name):
- self.add_message('redefined-outer-name', args=(name, line), node=stmt)
+ if not dummy_rgx.match(name):
+ self.add_message('redefined-outer-name',
+ args=(name, line), node=stmt)
elif is_builtin(name):
# do not print Redefining builtin for additional builtins
self.add_message('redefined-builtin', args=name, node=stmt)