Skip to content

Commit 0390485

Browse files
authored
Consider import * to be an explicit re-export (#11867)
Resolves #11856 Co-authored-by: hauntsaninja <>
1 parent d168b6d commit 0390485

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

mypy/semanal.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,12 +2041,10 @@ def visit_import_all(self, i: ImportAll) -> None:
20412041
if self.process_import_over_existing_name(
20422042
name, existing_symbol, node, i):
20432043
continue
2044-
# In stub files, `from x import *` always reexports the symbols.
2045-
# In regular files, only if implicit reexports are enabled.
2046-
module_public = self.is_stub_file or self.options.implicit_reexport
2044+
# `from x import *` always reexports symbols
20472045
self.add_imported_symbol(name, node, i,
2048-
module_public=module_public,
2049-
module_hidden=not module_public)
2046+
module_public=True,
2047+
module_hidden=False)
20502048

20512049
else:
20522050
# Don't add any dummy symbols for 'from x import *' if 'x' is unknown.

test-data/unit/check-flags.test

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,17 +1562,7 @@ __all__ = ('b',)
15621562
[out]
15631563
main:2: error: Module "other_module_2" does not explicitly export attribute "a"; implicit reexport disabled
15641564

1565-
[case testNoImplicitReexportStarConsideredImplicit]
1566-
# flags: --no-implicit-reexport
1567-
from other_module_2 import a
1568-
[file other_module_1.py]
1569-
a = 5
1570-
[file other_module_2.py]
1571-
from other_module_1 import *
1572-
[out]
1573-
main:2: error: Module "other_module_2" does not explicitly export attribute "a"; implicit reexport disabled
1574-
1575-
[case testNoImplicitReexportStarCanBeReexportedWithAll]
1565+
[case testNoImplicitReexportStarConsideredExplicit]
15761566
# flags: --no-implicit-reexport
15771567
from other_module_2 import a
15781568
from other_module_2 import b
@@ -1583,8 +1573,6 @@ b = 6
15831573
from other_module_1 import *
15841574
__all__ = ('b',)
15851575
[builtins fixtures/tuple.pyi]
1586-
[out]
1587-
main:2: error: Module "other_module_2" does not explicitly export attribute "a"; implicit reexport disabled
15881576

15891577
[case testNoImplicitReexportGetAttr]
15901578
# flags: --no-implicit-reexport --python-version 3.7

0 commit comments

Comments
 (0)