@singledispatchmethod 无法正常工作
@singledispatchmethod is not working correctly
@singledispatchmethod 工作不正常。我有这个代码
class Stream:
@singledispatchmethod
def subscribe(self, arg_1, arg_2):
pass
@subscribe.register
def _(self, msg_type: type, action: Callable):
pass
@subscribe.register
def _(self, msg_type: type, context: bool):
pass
def aaa() -> None:
pass
@pytest.mark.asyncio
async def test_can_subscribe_to_specific_event_types():
stream = Stream()
stream.subscribe(type(str), aaa)
我想调用一个需要
的方法的重载
def _(self, msg_type: type, action: Callable):
但 python 呼叫
def _(self, msg_type: type, context: bool):
我做错了什么?
When defining a function using @singledispatchmethod, note that the
dispatch happens on the type of the first non-self or non-cls
argument
你的情况是msg_type
。
@singledispatchmethod 工作不正常。我有这个代码
class Stream:
@singledispatchmethod
def subscribe(self, arg_1, arg_2):
pass
@subscribe.register
def _(self, msg_type: type, action: Callable):
pass
@subscribe.register
def _(self, msg_type: type, context: bool):
pass
def aaa() -> None:
pass
@pytest.mark.asyncio
async def test_can_subscribe_to_specific_event_types():
stream = Stream()
stream.subscribe(type(str), aaa)
我想调用一个需要
的方法的重载def _(self, msg_type: type, action: Callable):
但 python 呼叫
def _(self, msg_type: type, context: bool):
我做错了什么?
When defining a function using @singledispatchmethod, note that the dispatch happens on the type of the first non-self or non-cls argument
你的情况是msg_type
。