Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ef5376e

Browse files
authored
bpo-46290: Fix parameter names in dataclasses docs (GH-30450)
1 parent 45d44b9 commit ef5376e

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

Doc/library/dataclasses.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,9 @@ Module contents
319319
Raises :exc:`TypeError` if not passed a dataclass or instance of one.
320320
Does not return pseudo-fields which are ``ClassVar`` or ``InitVar``.
321321

322-
.. function:: asdict(instance, *, dict_factory=dict)
322+
.. function:: asdict(obj, *, dict_factory=dict)
323323

324-
Converts the dataclass ``instance`` to a dict (by using the
324+
Converts the dataclass ``obj`` to a dict (by using the
325325
factory function ``dict_factory``). Each dataclass is converted
326326
to a dict of its fields, as ``name: value`` pairs. dataclasses, dicts,
327327
lists, and tuples are recursed into. Other objects are copied with
@@ -346,14 +346,14 @@ Module contents
346346

347347
To create a shallow copy, the following workaround may be used::
348348

349-
dict((field.name, getattr(instance, field.name)) for field in fields(instance))
349+
dict((field.name, getattr(obj, field.name)) for field in fields(obj))
350350

351-
:func:`asdict` raises :exc:`TypeError` if ``instance`` is not a dataclass
351+
:func:`asdict` raises :exc:`TypeError` if ``obj`` is not a dataclass
352352
instance.
353353

354-
.. function:: astuple(instance, *, tuple_factory=tuple)
354+
.. function:: astuple(obj, *, tuple_factory=tuple)
355355

356-
Converts the dataclass ``instance`` to a tuple (by using the
356+
Converts the dataclass ``obj`` to a tuple (by using the
357357
factory function ``tuple_factory``). Each dataclass is converted
358358
to a tuple of its field values. dataclasses, dicts, lists, and
359359
tuples are recursed into. Other objects are copied with
@@ -366,9 +366,9 @@ Module contents
366366

367367
To create a shallow copy, the following workaround may be used::
368368

369-
tuple(getattr(instance, field.name) for field in dataclasses.fields(instance))
369+
tuple(getattr(obj, field.name) for field in dataclasses.fields(obj))
370370

371-
:func:`astuple` raises :exc:`TypeError` if ``instance`` is not a dataclass
371+
:func:`astuple` raises :exc:`TypeError` if ``obj`` is not a dataclass
372372
instance.
373373

374374
.. function:: make_dataclass(cls_name, fields, *, bases=(), namespace=None, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False)
@@ -406,10 +406,10 @@ Module contents
406406
def add_one(self):
407407
return self.x + 1
408408

409-
.. function:: replace(instance, /, **changes)
409+
.. function:: replace(obj, /, **changes)
410410

411-
Creates a new object of the same type as ``instance``, replacing
412-
fields with values from ``changes``. If ``instance`` is not a Data
411+
Creates a new object of the same type as ``obj``, replacing
412+
fields with values from ``changes``. If ``obj`` is not a Data
413413
Class, raises :exc:`TypeError`. If values in ``changes`` do not
414414
specify fields, raises :exc:`TypeError`.
415415

@@ -434,7 +434,7 @@ Module contents
434434
``replace()`` (or similarly named) method which handles instance
435435
copying.
436436

437-
.. function:: is_dataclass(class_or_instance)
437+
.. function:: is_dataclass(obj)
438438

439439
Return ``True`` if its parameter is a dataclass or an instance of one,
440440
otherwise return ``False``.

0 commit comments

Comments
 (0)