Author terry.reedy
Recipients eric.smith, jmg, rhettinger, terry.reedy
Date 2020-11-21.03:50:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1605930602.87.0.907726900492.issue42414@roundup.psfhosted.org>
In-reply-to
Content
Documenting dataclass fields strikes me as a reasonable request.  Since most most field values cannot have a  .__doc__ attribute...

> It could be stored in the dataclass-specific data attached to a class, 

The obvious place.

> but then you'd have to use a dataclass-specific function to get access to it. 

There are already at least 2 functions for getting docstrings for objects without .__doc__.  They could be enhanced with a dataclass-specific clause.

If ob.__doc__ is None, inspect.getdoc(ob) looks for a docstring elsewhere and sometimes succeeds.  For this reason, I just changed IDLE calltips to use getdoc for calltips.  If dataclasses.is_dataclass(ob.__class__), then I presume getdoc could retrieve the docstring from ob.__class__.__dataclass_fields__.

help(ob) uses pydoc, which gets docstrings with _getowndoc and if needed, _finddoc.  Perhaps these should be replaced with inspect.getdoc, but until then, _finddoc could have an elif clause added for dataclass fields.
History
Date User Action Args
2020-11-21 03:50:02terry.reedysetrecipients: + terry.reedy, rhettinger, eric.smith, jmg
2020-11-21 03:50:02terry.reedysetmessageid: <1605930602.87.0.907726900492.issue42414@roundup.psfhosted.org>
2020-11-21 03:50:02terry.reedylinkissue42414 messages
2020-11-21 03:50:01terry.reedycreate