Differentiate between unused 'import X' and unused 'from X import *' From: Daniel Drake Index: pylint-0.12.2/checkers/variables.py =================================================================== --- pylint-0.12.2.orig/checkers/variables.py +++ pylint-0.12.2/checkers/variables.py @@ -61,7 +61,10 @@ MSGS = { 'Used when a variable is defined but not used.'), 'W0613': ('Unused argument %r', 'Used when a function or method argument is not used.'), - + 'W0614': ('Unused import %s from wildcard import', + 'Used when an imported module or variable is not used from a \ + \'from X import *\' style import.'), + 'W0621': ('Redefining name %r from outer scope (line %s)', 'Used when a variable\'s name hide a name defined in the outer \ scope.'), @@ -134,9 +137,13 @@ builtins. Remember that you should avoid return for name, stmts in not_consumed.items(): stmt = stmts[0] - if isinstance(stmt, astng.Import) or ( - isinstance(stmt, astng.From) and stmt.modname != '__future__'): + if isinstance(stmt, astng.Import): self.add_message('W0611', args=name, node=stmt) + if isinstance(stmt, astng.From) and stmt.modname != '__future__': + if stmt.names[0][0] == '*': + self.add_message('W0614', args=name, node=stmt) + else: + self.add_message('W0611', args=name, node=stmt) del self._to_consume del self._vars