summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-07-09 18:51:35 (GMT)
committerGitHub <noreply@github.com>2022-07-09 18:51:35 (GMT)
commit7b5737a51ac2f67ab1c1c1fdee75fbb59fd123ea (patch)
tree135376b0ffa7a2444f1b94d2dbb73f92bcaaf612
parenta61870e19602f54a0579dd83edf334ba00ad92f6 (diff)
downloadcpython-7b5737a51ac2f67ab1c1c1fdee75fbb59fd123ea.zip
cpython-7b5737a51ac2f67ab1c1c1fdee75fbb59fd123ea.tar.gz
cpython-7b5737a51ac2f67ab1c1c1fdee75fbb59fd123ea.tar.bz2
Improve dataclass docstring (gh-94686)
(cherry picked from commit a10cf2f6b3766f9dbbe54bdaacfb3f2ca406ea3d) Co-authored-by: Tom Fryers <61272761+TomFryers@users.noreply.github.com>
-rw-r--r--Lib/dataclasses.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/Lib/dataclasses.py b/Lib/dataclasses.py
index 69cab8c..103ecba 100644
--- a/Lib/dataclasses.py
+++ b/Lib/dataclasses.py
@@ -1193,19 +1193,18 @@ def _add_slots(cls, is_frozen, weakref_slot):
def dataclass(cls=None, /, *, init=True, repr=True, eq=True, order=False,
unsafe_hash=False, frozen=False, match_args=True,
kw_only=False, slots=False, weakref_slot=False):
- """Returns the same class as was passed in, with dunder methods
- added based on the fields defined in the class.
+ """Add dunder methods based on the fields defined in the class.
Examines PEP 526 __annotations__ to determine fields.
- If init is true, an __init__() method is added to the class. If
- repr is true, a __repr__() method is added. If order is true, rich
+ If init is true, an __init__() method is added to the class. If repr
+ is true, a __repr__() method is added. If order is true, rich
comparison dunder methods are added. If unsafe_hash is true, a
- __hash__() method function is added. If frozen is true, fields may
- not be assigned to after instance creation. If match_args is true,
- the __match_args__ tuple is added. If kw_only is true, then by
- default all fields are keyword-only. If slots is true, an
- __slots__ attribute is added.
+ __hash__() method is added. If frozen is true, fields may not be
+ assigned to after instance creation. If match_args is true, the
+ __match_args__ tuple is added. If kw_only is true, then by default
+ all fields are keyword-only. If slots is true, a new class with a
+ __slots__ attribute is returned.
"""
def wrap(cls):