diff --git a/mypy/semanal.py b/mypy/semanal.py index 6c4697d64b00..6a481427d64e 100644 --- a/mypy/semanal.py +++ b/mypy/semanal.py @@ -493,10 +493,6 @@ def __init__( # since it's possible that the name will be there once the namespace is complete. self.incomplete_namespaces = incomplete_namespaces self.all_exports: list[str] = [] - # Map from module id to list of explicitly exported names (i.e. names in __all__). - # This is used by stubgen/stubtest, DO NOT use for any other purposes as it is - # not populated on incremental runs (nor in parallel mode). - self.export_map: dict[str, list[str]] = {} self.plugin = plugin # If True, process function definitions. If False, don't. This is used # for processing module top levels in fine-grained incremental mode. @@ -724,7 +720,6 @@ def refresh_top_level(self, file_node: MypyFile) -> None: if file_node.fullname == "typing_extensions": self.add_typing_extension_aliases(file_node) self.adjust_public_exports() - self.export_map[self.cur_mod_id] = self.all_exports self.all_exports = [] def add_implicit_module_attrs(self, file_node: MypyFile) -> None: diff --git a/mypy/stubgen.py b/mypy/stubgen.py index 60fbd7f43c0f..5d6149b97507 100755 --- a/mypy/stubgen.py +++ b/mypy/stubgen.py @@ -1773,7 +1773,9 @@ def generate_asts_for_modules( mod.ast = res.graph[mod.module].tree # Use statically inferred __all__ if there is no runtime one. if mod.runtime_all is None: - mod.runtime_all = res.manager.semantic_analyzer.export_map[mod.module] + mod_names = res.manager.semantic_analyzer.modules[mod.module].names + if "__all__" in mod_names: + mod.runtime_all = [name for name, sym in mod_names.items() if sym.module_public] def generate_stub_for_py_module(