【发布时间】:2023-01-20 23:44:09
【问题描述】:
我正在寻找可用于注释导入的实例方法的 Method 类型,因为 Callable[[Self, ...], ...] 不起作用。
例子:
mod_method.py
from __future__ import annotations
import typing
if typing.TYPE_CHECKING:
from class import Object
def meth_method(self: Object, val: int) -> float:
return val + 10.5
类.py
from mod_method import meth_method
class Object:
method: Method[[int], float] = meth_method
【问题讨论】: