Skip to content
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

Do not consider import a.b as b an explicit reexport #14086

Merged
merged 3 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2466,7 +2466,7 @@ def visit_import(self, i: Import) -> None:
if as_id is not None:
base_id = id
imported_id = as_id
module_public = use_implicit_reexport or id.split(".")[-1] == as_id
module_public = use_implicit_reexport or id == as_id
else:
base_id = id.split(".")[0]
imported_id = base_id
Expand Down
8 changes: 8 additions & 0 deletions test-data/unit/check-modules.test
Original file line number Diff line number Diff line change
Expand Up @@ -1818,6 +1818,8 @@ m = n # E: Cannot assign multiple modules to name "m" without explicit "types.M
from stub import Iterable # E: Module "stub" does not explicitly export attribute "Iterable"
from stub import D # E: Module "stub" does not explicitly export attribute "D"
from stub import C
from stub import foo
from stub import bar # E: Module "stub" does not explicitly export attribute "bar"

c = C()
reveal_type(c.x) # N: Revealed type is "builtins.int"
Expand All @@ -1828,13 +1830,19 @@ reveal_type(it) # N: Revealed type is "typing.Iterable[builtins.int]"
from typing import Iterable
from substub import C as C
from substub import C as D
from package import foo as foo
import package.bar as bar

def fun(x: Iterable[str]) -> Iterable[int]: pass

[file substub.pyi]
class C:
x: int

[file package/foo.pyi]

[file package/bar.pyi]

[builtins fixtures/module.pyi]

[case testNoReExportFromStubsMemberType]
Expand Down