This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author NeilGirdhar
Recipients NeilGirdhar, eric.smith, sobolevn, veky
Date 2022-02-19.17:13:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1645290794.49.0.0234345786799.issue46757@roundup.psfhosted.org>
In-reply-to
Content
> I'm not crazy about adding a method to every dataclass just for the 0.1% of the times it's needed.

I'm not sure I totally understand the cost here.  You can have a single shared global function that you set on each dataclass.  So the only cost would be an entry in each dataclass type's dict.  Even if a user creates a thousand dataclasses, that should only be tens of killobytes in pointers.

> I think using hasattr or catching the exception is a better way to go.

If you choose this, then I think this should be documented under the __post_init__ saying that any time you define __post_init__, you should either be a final class, or else call super.  If you call super, you musteither use hasattr(super().__post_init__) or catch the exception.

I have to admit, I find this quite ugly from a user perspective.
History
Date User Action Args
2022-02-19 17:13:14NeilGirdharsetrecipients: + NeilGirdhar, eric.smith, veky, sobolevn
2022-02-19 17:13:14NeilGirdharsetmessageid: <1645290794.49.0.0234345786799.issue46757@roundup.psfhosted.org>
2022-02-19 17:13:14NeilGirdharlinkissue46757 messages
2022-02-19 17:13:14NeilGirdharcreate