From 99338227dfbd167d6d8fca4849282458231e3130 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Mon, 29 Dec 2025 16:57:32 -0800 Subject: [PATCH 1/2] Remove export_map logic Follow up to #20487 --- mypy/semanal.py | 5 ----- mypy/stubgen.py | 6 +++++- 2 files changed, 5 insertions(+), 6 deletions(-) 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..c92c966976f2 100755 --- a/mypy/stubgen.py +++ b/mypy/stubgen.py @@ -1773,7 +1773,11 @@ 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.runtime_all = [ + name + for name, sym in res.manager.semantic_analyzer.modules[mod.module].names.items() + if sym.module_public + ] def generate_stub_for_py_module( From d043dd65e557b0ad5e266af4a106180e55b51241 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Mon, 29 Dec 2025 17:40:19 -0800 Subject: [PATCH 2/2] . --- mypy/stubgen.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mypy/stubgen.py b/mypy/stubgen.py index c92c966976f2..5d6149b97507 100755 --- a/mypy/stubgen.py +++ b/mypy/stubgen.py @@ -1773,11 +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 = [ - name - for name, sym in res.manager.semantic_analyzer.modules[mod.module].names.items() - if sym.module_public - ] + 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(