我有这样的事情:from typing import TypeVar, Generic, TupleT = TypeVar('T')S = TypeVar('S')U = TypeVar('U')class Foo(Generic[T, S]): def get_type_vars(self) -> Tuple[TypeVar]: return #TODO how do I return T and S here?assert Foo().get_type_vars() == (T, S)有什么办法可以得到这种行为吗?我需要一种方法来找出 和S是T通用 Class 的 TypeVars Foo。有任何想法吗?我应该提到,我编写了一些类装饰器,并且该方法get_type_vars()将由装饰器添加到类中。self所以我所拥有的只是方法中的实例:def get_type_vars(self) -> Tuple[TypeVar]: return #TODO how do I return T and S here in case that self is an instance of Foo?
添加回答
举报
0/150
提交
取消
