gh-113878: Add doc parameter to dataclasses.field (gh-114051)

If using `slots=True`, the `doc` parameter ends up in the `__slots__` dict. The `doc` parameter is also in the corresponding `Field` object.
This commit is contained in:
sobolevn 2024-09-27 19:20:49 +03:00 committed by GitHub
parent 0a3577bdfc
commit 9c7657f099
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 81 additions and 21 deletions

View file

@ -463,6 +463,14 @@ class PydocDocTest(unittest.TestCase):
doc = pydoc.render_doc(BinaryInteger)
self.assertIn('BinaryInteger.zero', doc)
def test_slotted_dataclass_with_field_docs(self):
import dataclasses
@dataclasses.dataclass(slots=True)
class My:
x: int = dataclasses.field(doc='Docstring for x')
doc = pydoc.render_doc(My)
self.assertIn('Docstring for x', doc)
def test_mixed_case_module_names_are_lower_cased(self):
# issue16484
doc_link = get_pydoc_link(xml.etree.ElementTree)