Open cynecx opened 7 years ago
About that incompatible supertype error. Is it somehow possible to get mypy to print the difference between both types?
This actually looks like a bug, the original signature is:
@overload
def pop(self, k: _KT) -> _VT: ...
@overload
def pop(self, k: _KT, default: Union[_VT, _T] = ...) -> Union[_VT, _T]: ...
Also your idea to print the types seems reasonable, therefore I am also adding a usability label.
OK, I have finally found the crux here, mypy considers this unsafe because of arg kinds:
from typing import overload
class A:
@overload
def f(self) -> int: ...
@overload
def f(self, x: int = ...) -> float: ...
class B(A):
@overload
def f(self) -> int: ...
@overload
def f(self, x: int) -> float: ...
I am not sure how to convince mypy that it is actually a subtype, this would require a complex overload subtyping algorithm.
Running mypy with:
Issues:
Line number differ because the code above is only a snippet.
What am I missing here?