Skip to content

Commit 2d88e63

Browse files
bpo-37163: Make the obj argument of dataclasses.replace() a positional-only. (GH-14390)
1 parent 6915066 commit 2d88e63

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

Doc/library/dataclasses.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ Module-level decorators, classes, and functions
356356
def add_one(self):
357357
return self.x + 1
358358

359-
.. function:: replace(instance, **changes)
359+
.. function:: replace(instance, /, **changes)
360360

361361
Creates a new object of the same type of ``instance``, replacing
362362
fields with values from ``changes``. If ``instance`` is not a Data

Lib/dataclasses.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ class C(Base):
12061206
unsafe_hash=unsafe_hash, frozen=frozen)
12071207

12081208

1209-
def replace(obj, **changes):
1209+
def replace(obj, /, **changes):
12101210
"""Return a new object replacing specified fields with new values.
12111211
12121212
This is especially useful for frozen classes. Example usage:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The *obj* argument of :func:`dataclasses.replace` is positional-only now.

0 commit comments

Comments
 (0)