Skip to content

Disallow undesirable implicit reexport with ImportFrom#12704

Merged
hauntsaninja merged 2 commits into
python:masterfrom
hauntsaninja:noreexp
Jun 24, 2022
Merged

Disallow undesirable implicit reexport with ImportFrom#12704
hauntsaninja merged 2 commits into
python:masterfrom
hauntsaninja:noreexp

Conversation

@hauntsaninja
Copy link
Copy Markdown
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
Copy Markdown
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
Comment thread 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 <>
imgbot Bot pushed a commit to kkipngenokoech/pytest that referenced this pull request Apr 18, 2026
I'm fixing a bug in mypy's --no-implicit-reexport logic in
python/mypy#12704 and mypy-primer flagged this
imgbot Bot pushed a commit to kkipngenokoech/pytest that referenced this pull request Apr 18, 2026
I'm fixing a bug in mypy's --no-implicit-reexport logic in
python/mypy#12704 and mypy-primer flagged this
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