import typing as typ
T = typ.TypeVar("T")
X = typ.TypeVar("X")
class Base(typ.Generic[T, X]):
pass
class ChildInt(?):
pass
class InheritedInt(ChildInt[str]):
# should be equivalent to Base[int, str]
我想从Base[int, ???]
继承ChildInt
,其中ChildInt
是设置???
值的泛型。
我如何实现这一点?
import typing as typ
T = typ.TypeVar("T")
X = typ.TypeVar("X")
class Base(typ.Generic[T, X]):
pass
class ChildInt(Base[int, X]):
pass
class InheritedInt(ChildInt[str]):
# is equivalent to Base[int, str]