Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1758,6 +1758,8 @@ def visit_import_from(self, imp: ImportFrom) -> None:
# precedence, but doesn't seem to be important in most use cases.
node = SymbolTableNode(GDEF, self.modules[fullname])
else:
if id == as_id == '__all__' and module_id in self.export_map:
self.all_exports[:] = self.export_map[module_id]
node = module.names.get(id)

missing_submodule = False
Expand Down
18 changes: 18 additions & 0 deletions test-data/unit/check-modules.test
Original file line number Diff line number Diff line change
Expand Up @@ -2825,3 +2825,21 @@ from mystery import a, b as b, c as d
[out]
tmp/stub.pyi:1: error: Cannot find implementation or library stub for module named "mystery"
tmp/stub.pyi:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

[case testReExportAllInStub]
from m1 import C
from m1 import D # E: Module "m1" has no attribute "D"
C()
C(1) # E: Too many arguments for "C"
[file m1.pyi]
from m2 import *
[file m2.pyi]
from m3 import *
from m3 import __all__ as __all__
class D: pass
[file m3.pyi]
from m4 import C as C
__all__ = ['C']
[file m4.pyi]
class C: pass
[builtins fixtures/list.pyi]