KEMBAR78
Disallow undesirable implicit reexport with ImportFrom by hauntsaninja · Pull Request #12704 · python/mypy · GitHub
Skip to content

Conversation

hauntsaninja
Copy link
Collaborator

Fixes #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 #11707, which fixed cases involving
implicitly reexported symbols that shared the name of a module

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
@github-actions

This comment has been minimized.

hauntsaninja pushed a commit to hauntsaninja/pytest that referenced this pull request May 1, 2022
I'm fixing a bug in mypy's --no-implicit-reexport logic in
python/mypy#12704 and mypy-primer flagged this
@hauntsaninja
Copy link
Collaborator Author

Okay, I think this change might be good? Opened pytest-dev/pytest#9906 and psycopg/psycopg#287 for the two mypy-primer hits.

@hauntsaninja hauntsaninja marked this pull request as ready for review May 1, 2022 05:46
bluetech pushed a commit to pytest-dev/pytest that referenced this pull request May 1, 2022
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)
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@hauntsaninja hauntsaninja merged commit e046e20 into python:master Jun 24, 2022
@hauntsaninja hauntsaninja deleted the noreexp branch June 24, 2022 12:07
Gobot1234 pushed a commit to Gobot1234/mypy that referenced this pull request Aug 12, 2022
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 <>
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.

from module import submodule implicit reexport is allowed

2 participants