mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
bpo-43997: Add versionadded directives for to match_args, kw_only, and slots in dataclasses.dataclasses documentation (GH-25803)
This commit is contained in:
parent
d8389e3e50
commit
a5eabc9a39
1 changed files with 8 additions and 0 deletions
|
@ -168,6 +168,8 @@ Module-level decorators, classes, and functions
|
||||||
``__match_args__`` is already defined in the class, then
|
``__match_args__`` is already defined in the class, then
|
||||||
``__match_args__`` will not be generated.
|
``__match_args__`` will not be generated.
|
||||||
|
|
||||||
|
.. versionadded:: 3.10
|
||||||
|
|
||||||
- ``kw_only``: If true (the default value is ``False``), then all
|
- ``kw_only``: If true (the default value is ``False``), then all
|
||||||
fields will be marked as keyword-only. If a field is marked as
|
fields will be marked as keyword-only. If a field is marked as
|
||||||
keyword-only, then the only affect is that the :meth:`__init__`
|
keyword-only, then the only affect is that the :meth:`__init__`
|
||||||
|
@ -177,11 +179,15 @@ Module-level decorators, classes, and functions
|
||||||
:term:`parameter` glossary entry for details. Also see the
|
:term:`parameter` glossary entry for details. Also see the
|
||||||
``dataclasses.KW_ONLY`` section.
|
``dataclasses.KW_ONLY`` section.
|
||||||
|
|
||||||
|
.. versionadded:: 3.10
|
||||||
|
|
||||||
- ``slots``: If true (the default is ``False``), :attr:`__slots__` attribute
|
- ``slots``: If true (the default is ``False``), :attr:`__slots__` attribute
|
||||||
will be generated and new class will be returned instead of the original one.
|
will be generated and new class will be returned instead of the original one.
|
||||||
If :attr:`__slots__` is already defined in the class, then :exc:`TypeError`
|
If :attr:`__slots__` is already defined in the class, then :exc:`TypeError`
|
||||||
is raised.
|
is raised.
|
||||||
|
|
||||||
|
.. versionadded:: 3.10
|
||||||
|
|
||||||
``field``\s may optionally specify a default value, using normal
|
``field``\s may optionally specify a default value, using normal
|
||||||
Python syntax::
|
Python syntax::
|
||||||
|
|
||||||
|
@ -267,6 +273,8 @@ Module-level decorators, classes, and functions
|
||||||
This is used when the generated :meth:`__init__` method's
|
This is used when the generated :meth:`__init__` method's
|
||||||
parameters are computed.
|
parameters are computed.
|
||||||
|
|
||||||
|
.. versionadded:: 3.10
|
||||||
|
|
||||||
If the default value of a field is specified by a call to
|
If the default value of a field is specified by a call to
|
||||||
:func:`field()`, then the class attribute for this field will be
|
:func:`field()`, then the class attribute for this field will be
|
||||||
replaced by the specified ``default`` value. If no ``default`` is
|
replaced by the specified ``default`` value. If no ``default`` is
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue