summaryrefslogtreecommitdiff
path: root/pylint/checkers/variables.py
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2016-06-05 13:49:55 +0100
committerClaudiu Popa <pcmanticore@gmail.com>2016-06-05 13:51:47 +0100
commit724175b46ad78c9c98d33db3ad317ce71ba24670 (patch)
tree5c941974fe9d6bac3d206c93a9f51d5b95401a39 /pylint/checkers/variables.py
parentb3eda4369f5b217840bc8911fdf2725e8f1408c8 (diff)
downloadpylint-git-724175b46ad78c9c98d33db3ad317ce71ba24670.tar.gz
Make pylint work with the astroid's master branch, including the special model changes
One change was to check for BaseInstance instead of Instance when looking if an instance supports a given protocol. The latter is used for class instances, while the first one can be used for builtins as well. Also the global-variable-not-assigned code was simplified.
Diffstat (limited to 'pylint/checkers/variables.py')
-rw-r--r--pylint/checkers/variables.py23
1 files changed, 9 insertions, 14 deletions
diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py
index 943c73ea3..7f8ab7273 100644
--- a/pylint/checkers/variables.py
+++ b/pylint/checkers/variables.py
@@ -643,6 +643,7 @@ class VariablesChecker(BaseChecker):
if isinstance(frame, astroid.Module):
self.add_message('global-at-module-level', node=node)
return
+
module = frame.root()
default_message = True
for name in node.names:
@@ -651,23 +652,16 @@ class VariablesChecker(BaseChecker):
except astroid.NotFoundError:
# unassigned global, skip
assign_nodes = []
- for anode in assign_nodes:
- if anode.parent is None:
- # node returned for builtin attribute such as __file__,
- # __doc__, etc...
- continue
- if anode.frame() is frame:
- # same scope level assignment
- break
- else:
- if not _find_frame_imports(name, frame):
- self.add_message('global-variable-not-assigned',
- args=name, node=node)
- default_message = False
+
if not assign_nodes:
+ self.add_message('global-variable-not-assigned',
+ args=name, node=node)
+ default_message = False
continue
+
for anode in assign_nodes:
- if anode.parent is None:
+ if (isinstance(anode, astroid.AssignName)
+ and anode.name in module.special_attributes):
self.add_message('redefined-builtin', args=name, node=node)
break
if anode.frame() is module:
@@ -677,6 +671,7 @@ class VariablesChecker(BaseChecker):
# global undefined at the module scope
self.add_message('global-variable-undefined', args=name, node=node)
default_message = False
+
if default_message:
self.add_message('global-statement', node=node)