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 gsakkis
Recipients eric.smith, gsakkis, matrixise, rhettinger, xtreak
Date 2019-04-19.10:53:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1555671231.43.0.440597437056.issue36662@roundup.psfhosted.org>
In-reply-to
Content
> I think the best thing to do is write another decorator that adds this method. I've often thought that having a dataclasses_tools third-party module would be a good idea.

I'd be happy with a separate decorator in the standard library for adding these methods. Not so sure about a third-party module, the added value is probably not high enough to justify an extra dependency (assuming one is aware it exists in the first place).

> or assume the member type matches the type defined in the class. 

This doesn't seem an unreasonable assumption to me. If I'm using a dataclass, I probably care enough about its member types to bother declaring them and I wouldn't mind if a particular method expects that the members actually match the types. This behaviour would be clearly documented. 

Alternatively, if we go with a separate decorator, whether this assumption holds could be a parameter, something like:

    def add_asdict(cls, name='asdict', strict=True)
History
Date User Action Args
2019-04-19 10:53:51gsakkissetrecipients: + gsakkis, rhettinger, eric.smith, matrixise, xtreak
2019-04-19 10:53:51gsakkissetmessageid: <1555671231.43.0.440597437056.issue36662@roundup.psfhosted.org>
2019-04-19 10:53:51gsakkislinkissue36662 messages
2019-04-19 10:53:51gsakkiscreate