[issue42414] unable to document fields of dataclass
Andrei Kulakov
report at bugs.python.org
Tue Jul 20 13:27:47 EDT 2021
Andrei Kulakov <andrei.avk at gmail.com> added the comment:
I've put up a simple PoC PR adding a __field_doc__ optional dict attr to dataclass, which would add the docs to class docstring:
@dataclass
class A:
__field_doc__ = dict(num='number of widgets', total='total widgets')
total: int
num: int = 5
print(A.__doc__)
OUTPUT
---
A(total: int, num: int = 5)
num: int [5] -- number of widgets
total: int -- total widgets
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42414>
_______________________________________
More information about the Python-bugs-list
mailing list