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
commit067b083930d7aa751ac8d5698e90e49adeb63b2e (patch)
treef6e76325ac4af25dcfb56bc4409c97750a32772c /checkers/variables.py
parent29df6196ec16b8ad935de883d20985bd8c08684d (diff)
downloadpylint-067b083930d7aa751ac8d5698e90e49adeb63b2e.tar.gz
Improved messages text for unused imports.
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 e1ae0ec..3893a4a 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):