[Python-Dev] Think a dead import finding script would be handy? (original) (raw)

Jean-Paul Calderone exarkun at divmod.com
Mon Aug 18 01:09:53 CEST 2008


On Sun, 17 Aug 2008 15:04:58 -0700, Brett Cannon <brett at python.org> wrote:

On Sun, Aug 17, 2008 at 1:40 PM, Georg Brandl <g.brandl at gmx.net> wrote:

Brett Cannon schrieb:

After Christian mentioned how we could speed up interpreter start-up by removing some dead imports he found, I decided to write up a quick script that generates the AST for a source file and (very roughly) tries to find imports that are never used. People think it's worth tossing into Tools, even if it is kind of rough? Otherwise I might toss it into the sandbox or make a quick Google code project out of it.

Regardless, one interesting side-effect of the script is that beyond finding some extraneous imports in various places, it also found some holes in all. I have the script look for the definition of all and consider an import used if it is listed there. pylint already finds unused imports. It finds tons of other, relatively useless, stuff in the default configuration, but I'm sure it can be coaxed into only showing unused imports too. Does anyone ever run pylint over the stdlib on occasion?

Buildbot includes a pyflakes step.

Jean-Paul



More information about the Python-Dev mailing list