Message381521
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. |
|
Date |
User |
Action |
Args |
2020-11-21 03:50:02 | terry.reedy | set | recipients:
+ terry.reedy, rhettinger, eric.smith, jmg |
2020-11-21 03:50:02 | terry.reedy | set | messageid: <1605930602.87.0.907726900492.issue42414@roundup.psfhosted.org> |
2020-11-21 03:50:02 | terry.reedy | link | issue42414 messages |
2020-11-21 03:50:01 | terry.reedy | create | |
|