Improve dataclass docstring (gh-94686)

This commit is contained in:
Tom Fryers 2022-07-09 19:26:24 +01:00 committed by GitHub
parent 78307c7dc2
commit a10cf2f6b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1193,19 +1193,18 @@ def _add_slots(cls, is_frozen, weakref_slot):
def dataclass(cls=None, /, *, init=True, repr=True, eq=True, order=False, def dataclass(cls=None, /, *, init=True, repr=True, eq=True, order=False,
unsafe_hash=False, frozen=False, match_args=True, unsafe_hash=False, frozen=False, match_args=True,
kw_only=False, slots=False, weakref_slot=False): kw_only=False, slots=False, weakref_slot=False):
"""Returns the same class as was passed in, with dunder methods """Add dunder methods based on the fields defined in the class.
added based on the fields defined in the class.
Examines PEP 526 __annotations__ to determine fields. Examines PEP 526 __annotations__ to determine fields.
If init is true, an __init__() method is added to the class. If If init is true, an __init__() method is added to the class. If repr
repr is true, a __repr__() method is added. If order is true, rich is true, a __repr__() method is added. If order is true, rich
comparison dunder methods are added. If unsafe_hash is true, a comparison dunder methods are added. If unsafe_hash is true, a
__hash__() method function is added. If frozen is true, fields may __hash__() method is added. If frozen is true, fields may not be
not be assigned to after instance creation. If match_args is true, assigned to after instance creation. If match_args is true, the
the __match_args__ tuple is added. If kw_only is true, then by __match_args__ tuple is added. If kw_only is true, then by default
default all fields are keyword-only. If slots is true, an all fields are keyword-only. If slots is true, a new class with a
__slots__ attribute is added. __slots__ attribute is returned.
""" """
def wrap(cls): def wrap(cls):