
Oh, thanks for pointing out that issue. I've replaced __init_subclass__ on that example metaclass with __new__. -Erik -----Original Message----- From: James H-B <gobot1234yt@gmail.com> Sent: Wednesday, January 5, 2022 3:24 AM To: typing-sig@python.org Subject: [Typing-sig] Re: Dataclass Transform draft PEP Funnily enough this is something that's actually in the current spec: Example of using dataclass_transform to decorate a metaclass. ```py # Indicate that classes that use this metaclass default to synthesizing # comparison methods. @typing.dataclass_transform(eq_default=True, order_default=True) class ModelMeta(type): def __init_subclass__( cls, *, init: bool = True, frozen: bool = False, eq: bool = True, order: bool = True, ): ... class ModelBase(metaclass=ModelMeta): ... # Example of how this class would be used by code that imports # from this library: class CustomerModel(ModelBase, init=False, frozen=True, eq=False, order=False): id: int name: str ``` To make this actually work you'd need to do something like this (or define __new__ for the metaclass) ```py @typing.dataclass_transform(eq_default=True, order_default=True) class ModelBase(metaclass=ModelMeta): def __init_subclass__( cls, *, init: bool = True, frozen: bool = False, eq: bool = True, order: bool = True, ): ... class CustomerModel(ModelBase, init=False, frozen=True, eq=False, order=False): id: int name: str ``` _______________________________________________ Typing-sig mailing list -- typing-sig@python.org To unsubscribe send an email to typing-sig-leave@python.org https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.pytho... Member address: erik.debonte@microsoft.com