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

Don't reexport star-imported symbols when implicit reexports are disabled #7361

Merged
merged 3 commits into from
Aug 19, 2019

Conversation

bluetech
Copy link
Contributor

@bluetech bluetech commented Aug 17, 2019

Based on #7099, please see only the second commit.

Currently, in regular files, symbols imported into module A with from B import * are considered explicitly exported from module A as well, i.e.
they are considered part of module's A public API.

This behavior makes sense in stub files as a shorthand (and is specified
in PEP 484), but for regular files I think it is better to be explicit:
add the symbols to __all__.

Fixes #7042
Further discussion: #7042 (comment)

bluetech and others added 3 commits August 17, 2019 15:12
The natural expectation is that when a variable is explicitly added to a
module's `__all__`, the module explicitly means to export it.

Previously, this was not the case, and a `from [..] import [..] as [..]`
reexport was required by `--no-implicit-export` even if the variable is
listed in `__all__`.

Fixes python#7042
…bled

Currently, in regular files, symbols imported into module A with `from B
import *` are considered explicitly exported from module B as well, i.e.
they are considered part of module's B public API.

This behavior makes sense in stub files as a shorthand (and is specified
in PEP 484), but for regular files I think it is better to be explicit:
add the symbols to `__all__`.

Further discussion:
python#7042 (comment)
Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--no-implicit-reexport should treat names in __all__ as exported
2 participants