lazy import aware branch of pyflakes
John Arbash Meinel
john at arbash-meinel.com
Wed Feb 27 22:04:35 GMT 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Michael Hudson wrote:
| 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.
Sounds nice.
|
| It produces rather a for bzrlib currently (though some of it is noise:
| pyflakes complains at this sort of thing:
Rather a ???
|
| 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
|
|
Also thanks for doing this. We might consider adding it to the test suite (part
of our source tests), but we would need to get it clean first.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHxd5zJdeBCYSNAAMRAvobAJ9R0sN9yLNoaYF7ODTknJ+XDZurWwCgpeHd
QNERUEK1QPooPHRFKnoTz9g=
=aiHw
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list