Weird error message for incompatible override when using a TypeVar
for self
#12786
Labels
bug
mypy got something wrong
topic-error-reporting
How we report errors
topic-inheritance
Inheritance and incompatible overrides
topic-self-types
Types for self
topic-usability
Bug Report
Minimal repro:
mypy output:
Mypy playground link here: https://mypy-play.net/?mypy=latest&python=3.10&gist=26b60881cd02e608bb9e555db4c3f627
Expected Behavior
I'm not sure an error is even appropriate here: no incompatible override is reported for
__or__
.Even if an error is appropriate here, however, the error message is weird and garbled. According to the error message, mypy seems to think that
__ror__
in the superclass expects three arguments (it only expects two). It also seems to think the method in the subclass will returnIntFlag
(not necessarily true; the return type will be whateverself
is, andself
could be any subtype ofIntFlag
).The function that creates this error message is here:
mypy/mypy/messages.py
Line 824 in 9b4bce9
Mypy version used
The text was updated successfully, but these errors were encountered: