Make type hints generic
Trimatix opened this issue · comments
SerializableType.deserialize
requires any implementing classes to return SerializableType
and not their own class.
Fix this with something similar to:
TSelf = TypeVar("TSelf", bound="SerializableType")
class SerializableType(Protocol):
def serialize(self, **kwargs) -> PrimativeType: ...
@classmethod
def deserialize(cls: Type[TSelf], data: PrimativeType, **kwargs) -> TSelf: ..