Closed
Description
I am trying to validate the following example straight from the docs -- Here I renamed the two methods _
from the example to _int
and _bool
to obviate an issue already reported, i.e., python/mypy#2904
from functools import singledispatchmethod
class Negator:
@singledispatchmethod
def neg(self, arg):
raise NotImplementedError("Cannot negate a")
@neg.register
def _int(self, arg: int):
return -arg
@neg.register
def _bool(self, arg: bool):
return not arg
n = Negator()
n.neg(2)
n.neg(True)
When I run mypy checks on this file, I get the following errors:
negator.py:17: error: "singledispatchmethod[Any]" not callable
negator.py:18: error: "singledispatchmethod[Any]" not callable
Found 2 errors in 1 file (checked 1 source file)
Python 3.8.2
mypy 0.770
Metadata
Metadata
Assignees
Labels
No labels