autoflake icon indicating copy to clipboard operation
autoflake copied to clipboard

Populate __all__ to avoid unused name errors

Open jayvdb opened this issue 8 years ago • 2 comments

When a module imports many names from sub-modules, and does not include any code except for those imports, the module is obviously intended to hold names.

Those names should be put into __all__.

e.g. the following causes pyflakes errors, as Foo and Bar are unused:

from a.b import Foo
from a.c import Bar

To avoid this,

from a.b import Bar
from a.c import Foo

__all__ = ('Bar', 'Foo')

jayvdb avatar May 01 '17 22:05 jayvdb

This should be uncontroversial for any module named __init__, as exported names are one of the primary purposes of an __init__ , especially before PEP 420.

jayvdb avatar Jul 26 '17 02:07 jayvdb

This seems appropriate to me.

myint avatar Jul 26 '17 02:07 myint