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
{{ message }}
Repository navigation
Confusing error message: List item 0 has incompatible type "Type[Linear]"; expected "Type[Linear]" #10160
In some situations, mypy can report that there was an incompatible type X, but then say that the expected type was also X. Regardless of whether or not the program is correct or not, this error message is bad.
To Reproduce
from typing import Any
class Linear:
def __init__(self, **kwargs) -> None:
pass
class QatLinear(Linear):
def __init__(self, qconfig=None):
pass
def f(x: Any):
if type(x) in [Linear, QatLinear]:
pass
Expected Behavior mypy gives me a good error message
Actual Behavior
(base) ezyang-mbp:~ ezyang$ mypy t.py
t.py:12: error: List item 0 has incompatible type "Type[Linear]"; expected "Type[Linear]"
Found 1 error in 1 file (checked 1 source file)
Your Environment
Mypy version used: mypy 0.780
Mypy command-line flags: none
Mypy configuration options from mypy.ini (and other config files): none
Activity
ezyang commentedon Mar 3, 2021
Possibly related: #9756
EugeneN commentedon Oct 27, 2022
this happens quite often btw
Make join of callables a bit more principled (python#22296)