You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
fromdataclassesimportdataclass@dataclassclassA:
x: strclassB:
A=AmatchA("y"):
caseB.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