Closed
Description
Bug Report
mypy errors with "Cannot determine type" of an input argument when using structural pattern matching against a class set as an attribute of another class.
To Reproduce
Example:
from dataclasses import dataclass
@dataclass
class A:
x: str
class B:
A = A
match A("y"):
case B.A(z):
# mypy: error: Cannot determine type of "z"
# correctly prints: "x: y"
print(f"x: {z}")
case A
works fine, as does defining A
directly inside B
instead of setting A = A
.
Expected Behavior
I don't get the mypy error above.
Actual Behavior
I get the error.
Your Environment
Mypy version used: 0.971 (compiled: yes)
Python version used: 3.10.4
Operating system and version: Ubuntu 22.04