lazy import aware branch of pyflakes
Michael Hudson
michael.hudson at canonical.com
Thu Feb 28 00:03:13 GMT 2008
John Arbash Meinel wrote:
> -----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.
Thanks.
> |
> | It produces rather a for bzrlib currently (though some of it is noise:
> | pyflakes complains at this sort of thing:
>
> Rather a ???
I don't understand your comment here -- are you just saying that you
don't understand my comment? :)
> |
> | 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.
I don't know how feasible that is -- one idea is to have a ratchet,
which says that each commit much not increase the number of pyflakes
complaints, or something.
Cheers,
mwh
More information about the bazaar
mailing list