diff options
author | sobolevn <mail@sobolevn.me> | 2024-09-27 16:20:49 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-27 16:20:49 (GMT) |
commit | 9c7657f09914254724683d91177aed7947637be5 (patch) | |
tree | a3866271b1a8ad5602e12f64ac03de1a7b463c66 /Doc | |
parent | 0a3577bdfcb7132c92a3f7fb2ac231bc346383c0 (diff) | |
download | cpython-9c7657f09914254724683d91177aed7947637be5.zip cpython-9c7657f09914254724683d91177aed7947637be5.tar.gz cpython-9c7657f09914254724683d91177aed7947637be5.tar.bz2 |
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.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/dataclasses.rst | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst index 1457392..51c1a42 100644 --- a/Doc/library/dataclasses.rst +++ b/Doc/library/dataclasses.rst @@ -231,7 +231,7 @@ Module contents follows a field with a default value. This is true whether this occurs in a single class, or as a result of class inheritance. -.. function:: field(*, default=MISSING, default_factory=MISSING, init=True, repr=True, hash=None, compare=True, metadata=None, kw_only=MISSING) +.. function:: field(*, default=MISSING, default_factory=MISSING, init=True, repr=True, hash=None, compare=True, metadata=None, kw_only=MISSING, doc=None) For common and simple use cases, no other functionality is required. There are, however, some dataclass features that @@ -300,6 +300,10 @@ Module contents .. versionadded:: 3.10 + - ``doc``: optional docstring for this field. + + .. versionadded:: 3.13 + If the default value of a field is specified by a call to :func:`!field`, then the class attribute for this field will be replaced by the specified *default* value. If *default* is not |