mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
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:
parent
0a3577bdfc
commit
9c7657f099
5 changed files with 81 additions and 21 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue