Neil Girdhar <mistersh...@gmail.com> added the comment:

@Raymond yeah I've been thinking about this some more, and there's no way to 
have a "top level" method with the dataclass decorator.

I think I will make a case to have a class version of dataclasses that works 
with inheritance.  Class versions of dataclasses are used in some places like 
here: https://github.com/google/flax/blob/main/flax/struct.py#L184
They just call dataclass on the class in __init_subclass__.

If we had something like this in the standard library, then you could put your 
empty __post_init__ in that class.  You could also make __init__ call super so 
that mixins would be initialized (right now the collider pattern you showed 
also breaks if B is not a dataclass, and has a non-trivial __init__).

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46757>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to