multimethod
multimethod copied to clipboard
Not work Callable[]
Hello. I am trying to use Callable in my code. But I get the error multimethod.DispatchError: ('from_producer: 0 methods found', (<class 'function'>,), []) .
What am I doing wrong?
from typing import Callable
from multimethod import multimethod
class AAA():
@staticmethod
@multimethod
def from_producer(producer: Callable[..., int]) -> None:
q = 1
@staticmethod
@multimethod
def from_producer(producer: int) -> None:
q = 1
def qwerty() -> int:
return 1
def test_1():
AAA.from_producer(qwerty)
One problem is that staticmethod has to be applied last (once).
class AAA():
@multimethod
def from_producer(producer: Callable[..., int]) -> None:
q = 1
@staticmethod
@multimethod
def from_producer(producer: int) -> None:
q = 1
And then 857e4e9 has as additional fix for an infinite recursion problem.