Skip to content

Fix minor docstring issues in dataclasses.py #93024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Lib/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,7 @@ def asdict(obj, *, dict_factory=dict):
"""Return the fields of a dataclass instance as a new dictionary mapping
field names to field values.

Example usage:
Example usage::

@dataclass
class C:
Expand Down Expand Up @@ -1322,8 +1322,8 @@ class C:
x: int
y: int

c = C(1, 2)
assert astuple(c) == (1, 2)
c = C(1, 2)
assert astuple(c) == (1, 2)

If given, 'tuple_factory' will be used instead of built-in tuple.
The function applies recursively to field values that are
Expand Down Expand Up @@ -1372,11 +1372,11 @@ def make_dataclass(cls_name, fields, *, bases=(), namespace=None, init=True,
The dataclass name will be 'cls_name'. 'fields' is an iterable
of either (name), (name, type) or (name, type, Field) objects. If type is
omitted, use the string 'typing.Any'. Field objects are created by
the equivalent of calling 'field(name, type [, Field-info])'.
the equivalent of calling 'field(name, type [, Field-info])'.::

C = make_dataclass('C', ['x', ('y', int), ('z', int, field(init=False))], bases=(Base,))

is equivalent to:
is equivalent to::

@dataclass
class C(Base):
Expand Down Expand Up @@ -1440,7 +1440,7 @@ def exec_body_callback(ns):
def replace(obj, /, **changes):
"""Return a new object replacing specified fields with new values.

This is especially useful for frozen classes. Example usage:
This is especially useful for frozen classes. Example usage::

@dataclass(frozen=True)
class C:
Expand All @@ -1450,7 +1450,7 @@ class C:
c = C(1, 2)
c1 = replace(c, x=3)
assert c1.x == 3 and c1.y == 2
"""
"""

# We're going to mutate 'changes', but that's okay because it's a
# new dict, even if called with 'replace(obj, **my_changes)'.
Expand Down