From 7c309ff404cbf7e33677bf416cb5486cf824275d Mon Sep 17 00:00:00 2001 From: bzoracler Date: Tue, 23 Dec 2025 07:57:45 +1300 Subject: [PATCH 1/2] fix: prevent leaking generated intersections to star imports --- mypy/checker.py | 2 +- test-data/unit/check-modules.test | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/mypy/checker.py b/mypy/checker.py index f90fc4be41f4..bfa9d6b71b24 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -5968,7 +5968,7 @@ def _make_fake_typeinfo_and_full_name( errors.append((pretty_names_list, "would have incompatible method signatures")) return None - curr_module.names[full_name] = SymbolTableNode(GDEF, info) + curr_module.names[full_name] = SymbolTableNode(GDEF, info, False) return Instance(info, [], extra_attrs=instances[0].extra_attrs or instances[1].extra_attrs) def intersect_instance_callable(self, typ: Instance, callable_type: CallableType) -> Instance: diff --git a/test-data/unit/check-modules.test b/test-data/unit/check-modules.test index 8faacb1a95f8..fd81765f5624 100644 --- a/test-data/unit/check-modules.test +++ b/test-data/unit/check-modules.test @@ -593,6 +593,25 @@ x = 1 [file m2.py] x = 1 +[case testStarImportDoesNotImportGeneratedIntersections] +from m1 import * +from m2 import * +[file m1.py] +from m3 import A, B + +a: A +if isinstance(a, B): ... +[file m2.py] +from m3 import A, B + +a: A +if isinstance(a, B): ... +[file m3.py] +class A: ... +class B: ... +class AB(A, B): ... +[builtins fixtures/isinstance.pyi] + [case testAssignToFuncDefViaImport] # Errors differ with the new analyzer. (Old analyzer gave error on the From 642cf64073da603a4efc7befa6b90de9300eb677 Mon Sep 17 00:00:00 2001 From: bzoracler Date: Tue, 23 Dec 2025 07:59:26 +1300 Subject: [PATCH 2/2] fix: prevent stubtest from detecting generated intersections --- mypy/checker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/checker.py b/mypy/checker.py index bfa9d6b71b24..96e41a5e1786 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -5968,7 +5968,7 @@ def _make_fake_typeinfo_and_full_name( errors.append((pretty_names_list, "would have incompatible method signatures")) return None - curr_module.names[full_name] = SymbolTableNode(GDEF, info, False) + curr_module.names[full_name] = SymbolTableNode(GDEF, info, False, module_hidden=True) return Instance(info, [], extra_attrs=instances[0].extra_attrs or instances[1].extra_attrs) def intersect_instance_callable(self, typ: Instance, callable_type: CallableType) -> Instance: