bpo-37163: Make the obj argument of dataclasses.replace() a positional-only. (GH-14390)

This commit is contained in:
Serhiy Storchaka 2019-06-26 19:07:44 +03:00 committed by GitHub
parent 69150669f2
commit 2d88e63bfc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 2 deletions

View File

@ -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

View File

@ -1206,7 +1206,7 @@ def make_dataclass(cls_name, fields, *, bases=(), namespace=None, init=True,
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:

View File

@ -0,0 +1 @@
The *obj* argument of :func:`dataclasses.replace` is positional-only now.