mirror of
https://github.com/python/cpython.git
synced 2025-09-22 08:23:36 +00:00
bpo-37163: Make the obj argument of dataclasses.replace() a positional-only. (GH-14390)
This commit is contained in:
parent
69150669f2
commit
2d88e63bfc
3 changed files with 3 additions and 2 deletions
|
@ -356,7 +356,7 @@ Module-level decorators, classes, and functions
|
||||||
def add_one(self):
|
def add_one(self):
|
||||||
return self.x + 1
|
return self.x + 1
|
||||||
|
|
||||||
.. function:: replace(instance, **changes)
|
.. function:: replace(instance, /, **changes)
|
||||||
|
|
||||||
Creates a new object of the same type of ``instance``, replacing
|
Creates a new object of the same type of ``instance``, replacing
|
||||||
fields with values from ``changes``. If ``instance`` is not a Data
|
fields with values from ``changes``. If ``instance`` is not a Data
|
||||||
|
|
|
@ -1206,7 +1206,7 @@ def make_dataclass(cls_name, fields, *, bases=(), namespace=None, init=True,
|
||||||
unsafe_hash=unsafe_hash, frozen=frozen)
|
unsafe_hash=unsafe_hash, frozen=frozen)
|
||||||
|
|
||||||
|
|
||||||
def replace(obj, **changes):
|
def replace(obj, /, **changes):
|
||||||
"""Return a new object replacing specified fields with new values.
|
"""Return a new object replacing specified fields with new values.
|
||||||
|
|
||||||
This is especially useful for frozen classes. Example usage:
|
This is especially useful for frozen classes. Example usage:
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
The *obj* argument of :func:`dataclasses.replace` is positional-only now.
|
Loading…
Add table
Add a link
Reference in a new issue