Trimatix / Carica

Python module that populates variables from TOML config documents, and generates config documents from python variables.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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: ..