-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Consider from .sub import *
as re-exporting all the public symbols of sub
#11856
Comments
Linking #8754 which is not the same but also has issues related to re-exports and is another discrepancy between mypy and Pyright. |
Thanks for flagging this, I'd be in favour of changing mypy's behaviour here. |
This change would make mypy consistent with the rules that (I thought) we had agreed to a while back when it comes to py.typed libraries. These rules are documented here, and they indicate that symbols imported through wildcard import statements should be treated as re-exported. |
Yes, Guido, you and I had agreed on a typing-sig thread at some point :-) #11867 will change mypy's behaviour to what we discussed. |
Resolves #11856 Co-authored-by: hauntsaninja <>
Resolves python#11856 Co-authored-by: hauntsaninja <>
Bug Report
This goes directly against what was made in #7361 but it's more consistent with PEP 484 which says:
I know that these notes are for "stub files" but, for typed libraries with a
py.typed
(see PEP 561), it makes sense for regular.py
files to follow the same rules as.pyi
files.Not considering
from .sub import *
as re-exporting all the public/exported symbols ofsub
forces the developers to manually list all the symbols ofsub
, making the attention they paid to correctly make symbols public or private in this sub module worthless.To Reproduce
Expected Behavior
__init__.py
exports:A
from.other
(notB
because it wasn't re-exported)public_function
from.sub
(not_private_function
because it's considered private as it starts with_
)sub
since this is what PEP 484 mentions in:This is consistent with what @erictraut did in Pyright.
Actual Behavior
__init__.py
only exportssub
.Your Environment
The text was updated successfully, but these errors were encountered: