Код: Выделить всё
from abc import ABC, abstractmethod
from typing import Generic, TypeVar
class Base(ABC):
@classmethod
@abstractmethod
def test(cls):
print('foo')
class B(Base):
@classmethod
def test(cls):
print('bar')
T = TypeVar("T", bound=Base)
class A(Generic[T]):
def invoke_test():
T.test()
a: A = A[B]
a.invoke_test()
Подробнее здесь: https://stackoverflow.com/questions/785 ... -parameter