Skip to content

Docs: show how --no-implicit-reexport handles from X import Y as Z #11083

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

Merged
merged 1 commit into from
Sep 9, 2021
Merged

Docs: show how --no-implicit-reexport handles from X import Y as Z #11083

merged 1 commit into from
Sep 9, 2021

Conversation

SyntaxColoring
Copy link
Contributor

@SyntaxColoring SyntaxColoring commented Sep 9, 2021

Description

In our testing, mypy appears to treat code like this as an implicit re-export. If --no-implicit-reexport is given, mypy will disallow it.

from X import Y as Z  # Non-matching name.

Even though it treats code like this as an explicit re-export:

from X import Y as Y  # Matching name.

For stub files specifically, PEP 484 has this note, emphasis mine:

Modules and variables imported into the stub are not considered exported from the stub unless the import uses the import ... as ... form or the equivalent from ... import ... as ... form. (UPDATE: To clarify, the intention here is that only names imported using the form X as X will be exported, i.e. the name before and after as must be the same.)

I am therefore assuming that this mypy behavior is intentional. (Even though I find it unfortunate and surprising, and even though --no-implicit-reexport seems meant for more than just stub files.) So this PR documents it.

Test Plan

  • Verify that the rendered docs look good: Screen Shot 2021-09-09 at 2 42 41 PM
  • If anyone can authoritatively confirm that this is indeed intended behavior of --no-implicit-reexport, that would be helpful.

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

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.

2 participants