Skip to content

Commit

Permalink
bpo-37163: Make the obj argument of dataclasses.replace() a positiona…
Browse files Browse the repository at this point in the history
…l-only. (GH-14390)
  • Loading branch information
serhiy-storchaka authored Jun 26, 2019
1 parent 6915066 commit 2d88e63
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Doc/library/dataclasses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ Module-level decorators, classes, and functions
def add_one(self):
return self.x + 1

.. function:: replace(instance, **changes)
.. function:: replace(instance, /, **changes)

Creates a new object of the same type of ``instance``, replacing
fields with values from ``changes``. If ``instance`` is not a Data
Expand Down
2 changes: 1 addition & 1 deletion Lib/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ class C(Base):
unsafe_hash=unsafe_hash, frozen=frozen)


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

0 comments on commit 2d88e63

Please sign in to comment.