-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Disallow undesirable implicit reexport with ImportFrom #12704
Conversation
Fixes python#12689 We always hid e.g. `import concurrent`, but looks like mypy never hid `from concurrent import futures`. It's possible this fix is pretty breaking for users, let's see what primer thinks. I last touched this logic in python#11707, which fixed cases involving implicitly reexported symbols that shared the name of a module
This comment has been minimized.
This comment has been minimized.
I'm fixing a bug in mypy's --no-implicit-reexport logic in python/mypy#12704 and mypy-primer flagged this
Okay, I think this change might be good? Opened pytest-dev/pytest#9906 and psycopg/psycopg#287 for the two mypy-primer hits. |
I'm fixing a bug in mypy's --no-implicit-reexport logic in python/mypy#12704 and mypy-primer flagged this
mypy/semanal.py
Outdated
or fullname not in self.modules | ||
# but given `from somewhere import random_unrelated_module` we should hide | ||
# random_unrelated_module | ||
or not fullname.startswith(self.cur_mod_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if there's a partial prefix, e.g. foo.ba
vs foo.bar
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, was a little sloppy. Fixed and added a test.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Fixes python#12689 We always hid e.g. `import concurrent`, but looks like mypy never hid `from concurrent import futures`. It's possible this fix is pretty breaking for users, let's see what primer thinks. I last touched this logic in python#11707, which fixed cases involving implicitly reexported symbols that shared the name of a module Co-authored-by: hauntsaninja <>
Fixes #12689
We always hid e.g.
import concurrent
, but looks like mypynever hid
from concurrent import futures
. It's possible this fix ispretty breaking for users, let's see what primer thinks.
I last touched this logic in #11707, which fixed cases involving
implicitly reexported symbols that shared the name of a module