Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populate __all__ to avoid unused name errors #16

Open
jayvdb opened this issue May 1, 2017 · 2 comments · May be fixed by #26
Open

Populate __all__ to avoid unused name errors #16

jayvdb opened this issue May 1, 2017 · 2 comments · May be fixed by #26

Comments

@jayvdb
Copy link
Member

jayvdb commented May 1, 2017

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
Copy link
Member Author

jayvdb commented Jul 26, 2017

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.

@myint
Copy link
Member

myint commented Jul 26, 2017

This seems appropriate to me.

adhikasp added a commit to adhikasp/autoflake that referenced this issue Aug 29, 2017
@adhikasp adhikasp linked a pull request Aug 29, 2017 that will close this issue
adhikasp added a commit to adhikasp/autoflake that referenced this issue Aug 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants