【发布时间】:2023-01-22 12:15:40
【问题描述】:
method 的正确类型提示是什么?有typing.Callable,但我正在寻找方法输入提示,typing.Callable[[Self, ...], ...] 不工作。
我试过这个但它不起作用:
class _Object:
"""An empty object for method type."""
def method(self) -> None:
"""
A method.
:return None: Nothing.
"""
return None
MethodType: Type = type(_Object().method)
方法类型是类型而不是类型别名.那我应该使用哪种类型?我正在使用 Python 3.11。
【问题讨论】:
标签: python methods python-typing