mypy
mypy copied to clipboard
singledispatchmethod decorated method fails with unknown method register
I played with an update of mypy from 0.931 to 0.971. The new version fails with error: "Callable[..., bool]" has no attribute "register"
The code is written oddly because of known Python issue https://bugs.python.org/issue41987 , the interpreter has no issue with it.
from functools import singledispatchmethod
class Issue:
@singledispatchmethod
def __contains__(self, other) -> bool:
return True
@Issue.__contains__.register
def _(self, other: Issue) -> bool:
return False
$ mypy issue.py
issue.py:12: error: "Callable[..., bool]" has no attribute "register"
Found 1 error in 1 file (checked 1 source file)