[Python-Dev] cpython (3.2): remove unused import

Christian Heimes lists at cheimes.de
Mon Feb 6 01:53:48 CET 2012


Am 06.02.2012 01:39, schrieb Brett Cannon:
> I'm going to assume pylint or pyflakes would throw too many warnings on
> the stdlib, but would it be worth someone's time to write a simple
> unused import checker to run over the stdlib on occasion? I bet even one
> that did nothing more than a regex search for matched import statements
> would be good enough.

Zope 3 has an import checker that uses the compiler package and AST tree
to check for unused imports. It seems like a better approach than a
simple regex search.

http://svn.zope.org/Zope3/trunk/utilities/importchecker.py?rev=25177&view=auto

The importorder tool uses the tokenizer module to order import statements.

http://svn.zope.org/Zope3/trunk/utilities/importorder.py?rev=25177&view=auto

Both are written by Jim Fulton.

Christian



More information about the Python-Dev mailing list