Код: Выделить всё
def foo[A: AMin, B: BMin, C: CMin](d: D[A, B, C], e: E[A, B]) -> F[C]: ...
Например. Импорт A, B, C в качестве граничного typevar из общего модуля.
, а также определения типа, такие как тип dtype = ...
Я попытался следовать с простотой (в Foo/foo2 defs), я надеялся достичь:
Код: Выделить всё
from typing import TypeVar
class AMin: pass
class BMin: pass
class CMin: pass
class D: pass
class E: pass
class F: pass
A = TypeVar('A', bound=AMin)
B = TypeVar('B', bound=BMin)
C = TypeVar('C', bound=CMin)
type DType = D[A, B, C]
type EType = E[A, B]
type FType = F[C]
def foo(d: DType, e: EType) -> FType: ...
def foo2(d: DType) -> C: ...
Подробнее здесь: https://stackoverflow.com/questions/794 ... definition