typet
typet copied to clipboard
Add support for Generics in Object and StrictObject
Currently, using Generics with Object is a pain. Initial support for casting and type validation exist, but creating the class itself is awkward as it requires creating a metaclass.
from typet import Object
from typing import Generic, GenericMeta, TypeVar
T = TypeVar('T')
class Meta(type(Object), GenericMeta): ...
class MyObject(Object, Generic[T], meta=Meta):
value: T