@@ -1255,7 +1255,7 @@ def asdict(obj, *, dict_factory=dict):
1255
1255
"""Return the fields of a dataclass instance as a new dictionary mapping
1256
1256
field names to field values.
1257
1257
1258
- Example usage:
1258
+ Example usage::
1259
1259
1260
1260
@dataclass
1261
1261
class C:
@@ -1326,8 +1326,8 @@ class C:
1326
1326
x: int
1327
1327
y: int
1328
1328
1329
- c = C(1, 2)
1330
- assert astuple(c) == (1, 2)
1329
+ c = C(1, 2)
1330
+ assert astuple(c) == (1, 2)
1331
1331
1332
1332
If given, 'tuple_factory' will be used instead of built-in tuple.
1333
1333
The function applies recursively to field values that are
@@ -1376,11 +1376,11 @@ def make_dataclass(cls_name, fields, *, bases=(), namespace=None, init=True,
1376
1376
The dataclass name will be 'cls_name'. 'fields' is an iterable
1377
1377
of either (name), (name, type) or (name, type, Field) objects. If type is
1378
1378
omitted, use the string 'typing.Any'. Field objects are created by
1379
- the equivalent of calling 'field(name, type [, Field-info])'.
1379
+ the equivalent of calling 'field(name, type [, Field-info])'.::
1380
1380
1381
1381
C = make_dataclass('C', ['x', ('y', int), ('z', int, field(init=False))], bases=(Base,))
1382
1382
1383
- is equivalent to:
1383
+ is equivalent to::
1384
1384
1385
1385
@dataclass
1386
1386
class C(Base):
@@ -1444,7 +1444,7 @@ def exec_body_callback(ns):
1444
1444
def replace (obj , / , ** changes ):
1445
1445
"""Return a new object replacing specified fields with new values.
1446
1446
1447
- This is especially useful for frozen classes. Example usage:
1447
+ This is especially useful for frozen classes. Example usage::
1448
1448
1449
1449
@dataclass(frozen=True)
1450
1450
class C:
@@ -1454,7 +1454,7 @@ class C:
1454
1454
c = C(1, 2)
1455
1455
c1 = replace(c, x=3)
1456
1456
assert c1.x == 3 and c1.y == 2
1457
- """
1457
+ """
1458
1458
1459
1459
# We're going to mutate 'changes', but that's okay because it's a
1460
1460
# new dict, even if called with 'replace(obj, **my_changes)'.
0 commit comments