
Jan. 7, 2022
9:58 a.m.
I think James is right. This should work with ordinary classes and inheritance. Using a metaclass when one isn't needed is simply bad design. Metaclasses are hard to mix and should be avoided unless necessary. If you can get away with using __init_subclass__, you should. Here's an example of a dataclass maker that is an ordinary class: https://github.com/google/flax/blob/main/flax/struct.py#L184. And as you can see they are forced to create an unnecessary metaclass merely to please the type-checker. At least, they don't do it unless TYPE_CHECKING is on, but it would be better for them not to have to do it at all. Please don't force dataclass-makers to be metaclasses.