Bug Report
Accessing a property typed to the object we access , e.g. a property defining __get__(self, obj: B, ...) through a Union[A,B] complains that the argument to __get__ has union type, despite being defined in B.
To Reproduce
https://mypy-play.net/?mypy=latest&python=3.11&gist=e7d68cb2fa9867b0c21c66f7b33637e5
Expected Behavior
No errors
Actual Behavior
main.py:35: error: Argument 1 to "__get__" of "SingleValueProperty" has incompatible type "Union[A, B]"; expected "B" [arg-type]
main.py:39: error: Argument 1 to "__get__" of "SingleValueProperty" has incompatible type "Union[A, B]"; expected "B" [arg-type]
Found 2 errors in 1 file (checked 1 source file)
Your Environment
The mypy playground.
- Mypy version used: 0.991, 0.971
- Mypy command-line flags:
- Mypy configuration options from
mypy.ini (and other config files):
- Python version used: 3.11
Bug Report
Accessing a property typed to the object we access , e.g. a property defining
__get__(self, obj: B, ...)through aUnion[A,B]complains that the argument to__get__has union type, despite being defined in B.To Reproduce
https://mypy-play.net/?mypy=latest&python=3.11&gist=e7d68cb2fa9867b0c21c66f7b33637e5
Expected Behavior
No errors
Actual Behavior
Your Environment
The mypy playground.
mypy.ini(and other config files):