Skip to content

Commit f744d87

Browse files
committed
Fix minor docstring issues in dataclasses.py.
Otherwise, when using `functools.wrap` around them (and inherit their docstrings), sphinx renders the docstrings badly and raises warnings about wrong indent.
1 parent 87b9b4e commit f744d87

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Lib/dataclasses.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,7 @@ def asdict(obj, *, dict_factory=dict):
12511251
"""Return the fields of a dataclass instance as a new dictionary mapping
12521252
field names to field values.
12531253
1254-
Example usage:
1254+
Example usage::
12551255
12561256
@dataclass
12571257
class C:
@@ -1322,8 +1322,8 @@ class C:
13221322
x: int
13231323
y: int
13241324
1325-
c = C(1, 2)
1326-
assert astuple(c) == (1, 2)
1325+
c = C(1, 2)
1326+
assert astuple(c) == (1, 2)
13271327
13281328
If given, 'tuple_factory' will be used instead of built-in tuple.
13291329
The function applies recursively to field values that are
@@ -1372,11 +1372,11 @@ def make_dataclass(cls_name, fields, *, bases=(), namespace=None, init=True,
13721372
The dataclass name will be 'cls_name'. 'fields' is an iterable
13731373
of either (name), (name, type) or (name, type, Field) objects. If type is
13741374
omitted, use the string 'typing.Any'. Field objects are created by
1375-
the equivalent of calling 'field(name, type [, Field-info])'.
1375+
the equivalent of calling 'field(name, type [, Field-info])'.::
13761376
13771377
C = make_dataclass('C', ['x', ('y', int), ('z', int, field(init=False))], bases=(Base,))
13781378
1379-
is equivalent to:
1379+
is equivalent to::
13801380
13811381
@dataclass
13821382
class C(Base):
@@ -1440,7 +1440,7 @@ def exec_body_callback(ns):
14401440
def replace(obj, /, **changes):
14411441
"""Return a new object replacing specified fields with new values.
14421442
1443-
This is especially useful for frozen classes. Example usage:
1443+
This is especially useful for frozen classes. Example usage::
14441444
14451445
@dataclass(frozen=True)
14461446
class C:
@@ -1450,7 +1450,7 @@ class C:
14501450
c = C(1, 2)
14511451
c1 = replace(c, x=3)
14521452
assert c1.x == 3 and c1.y == 2
1453-
"""
1453+
"""
14541454

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

0 commit comments

Comments
 (0)