summaryrefslogtreecommitdiff
path: root/checkers/variables.py
diff options
context:
space:
mode:
authorMichal Nowikowski <godfryd@gmail.com>2014-08-02 06:18:30 +0200
committerMichal Nowikowski <godfryd@gmail.com>2014-08-02 06:18:30 +0200
commit5ea88678edaa2768dfebfcd4b7a07a933d8e8e6f (patch)
tree4917261bc81241cf78b589b9ac0e766d0c56ce85 /checkers/variables.py
parent0f9ecef7c9e4616989ad0efec77a027013fa2270 (diff)
downloadpylint-git-5ea88678edaa2768dfebfcd4b7a07a933d8e8e6f.tar.gz
Improved messages text for unused imports.
--HG-- branch : fix-293
Diffstat (limited to 'checkers/variables.py')
-rw-r--r--checkers/variables.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/checkers/variables.py b/checkers/variables.py
index e1ae0ec43..3893a4ad2 100644
--- a/checkers/variables.py
+++ b/checkers/variables.py
@@ -170,7 +170,7 @@ MSGS = {
'global-at-module-level',
'Used when you use the "global" statement at the module level \
since it has no effect'),
- 'W0611': ('Unused import %s',
+ 'W0611': ('Unused %s',
'unused-import',
'Used when an imported module or variable is not used.'),
'W0612': ('Unused variable %r',
@@ -321,12 +321,20 @@ builtins. Remember that you should avoid to define new builtins when possible.'
continue
for stmt in stmts:
if isinstance(stmt, astroid.Import):
- self.add_message('unused-import', args=stmt.names[0][0], node=stmt)
+ if stmt.names[0][1] is None:
+ msg = "import %s" % stmt.names[0][0]
+ else:
+ msg = "%s imported as %s" % (stmt.names[0][0], stmt.names[0][1])
+ self.add_message('unused-import', args=msg, node=stmt)
elif isinstance(stmt, astroid.From) and stmt.modname != '__future__':
if stmt.names[0][0] == '*':
self.add_message('unused-wildcard-import', args=name, node=stmt)
else:
- self.add_message('unused-import', args=name, node=stmt)
+ if stmt.names[0][1] is None:
+ msg = "%s imported from %s" % stmt.names[0][0], stmt.modname
+ else:
+ msg = "%s imported from %s as %s" % (stmt.names[0][0], stmt.modname, stmt.names[0][1])
+ self.add_message('unused-import', args=msg, node=stmt)
del self._to_consume
def visit_class(self, node):