Bug Report, To Reproduce, & Actual Behaviour
Synthetic intersections leak in star imports, and if the intersection is created in different modules from the same intersectees, mypy reports "incompatible import" errors.
Run mypy on the following project:
$ mypy
src/pkg/__init__.py:2: error: Incompatible import of "<subclass of "pkg.m3.A" and "pkg.m3.B">" (imported name has type "type[pkg.m2.<subclass of "pkg.m3.A" and "pkg.m3.B">]", local name has type "type[pkg.m1.<subclass of "pkg.m3.A" and "pkg.m3.B">]") [assignment]
Project:
project/
mypy.ini
[mypy]
files = src/
src/
pkg/
__init__.py
from .m1 import *
from .m2 import *
m1.py
from .m3 import A, B
def f() -> None:
a: A
if isinstance(a, B): ...
m2.py
from .m3 import A, B
def f() -> None:
a: A
if isinstance(a, B): ...
m3.py
class A: ...
class B: ...
class AB(A, B): ...
The issue arises from the call to the SymbolTableNode constructor here, which probably should be passed module_public=False.
|
curr_module.names[full_name] = SymbolTableNode(GDEF, info) |
Expected Behavior
No issues
Your Environment
- Mypy version used: 1.19.1
- Mypy command-line flags: None
Bug Report, To Reproduce, & Actual Behaviour
Synthetic intersections leak in star imports, and if the intersection is created in different modules from the same intersectees, mypy reports "incompatible import" errors.
Run mypy on the following project:
Project:
The issue arises from the call to the
SymbolTableNodeconstructor here, which probably should be passedmodule_public=False.mypy/mypy/checker.py
Line 5971 in 72cff30
Expected Behavior
No issues
Your Environment