lazy import aware branch of pyflakes
Michael Hudson
michael.hudson at canonical.com
Wed Feb 27 21:54:32 GMT 2008
I got tired of cleaning up the imports of a couple of bzrlib files by
hand or by converting lazy imports to real imports, running pyflakes
and then lazifying the imports again, so I came up with a better way:
hacking pyflakes to understand lazy imports.
The branch at:
https://code.edge.launchpad.net/~mwhudson/pyflakes/lazy-import-support
does three things:
1) Parses lazy imports so that uses of the imported names don't give
'undefined name' warnings.
2) Warns if a lazily imported name is used at module level.
3) Warns for names that are imported eagerly but *not* used at module
level and so could be lazy.
It produces rather a for bzrlib currently (though some of it is noise:
pyflakes complains at this sort of thing:
import bzrlib.a_module
import bzrlib.another_module
which is probably a bug that should be fixed and submitted upstream).
Unless someone beats me to it, I'll probably submit branches that
clean some of this up, but the real value of a tool like this is
running it regularly to stop unused import cruft gathering, and I'll
try to do that too.
Cheers,
mwh
More information about the bazaar
mailing list