summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Doc/library/dataclasses.rst2
-rw-r--r--Lib/dataclasses.py2
-rw-r--r--Misc/NEWS.d/next/Library/2019-06-19-10-35-53.bpo-37163.9pPg2F.rst1
3 files changed, 3 insertions, 2 deletions
diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst
index db5c3e0..9e02882 100644
--- a/Doc/library/dataclasses.rst
+++ b/Doc/library/dataclasses.rst
@@ -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
diff --git a/Lib/dataclasses.py b/Lib/dataclasses.py
index b035cbb..5e57e20 100644
--- a/Lib/dataclasses.py
+++ b/Lib/dataclasses.py
@@ -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:
diff --git a/Misc/NEWS.d/next/Library/2019-06-19-10-35-53.bpo-37163.9pPg2F.rst b/Misc/NEWS.d/next/Library/2019-06-19-10-35-53.bpo-37163.9pPg2F.rst
new file mode 100644
index 0000000..07182e7
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2019-06-19-10-35-53.bpo-37163.9pPg2F.rst
@@ -0,0 +1 @@
+The *obj* argument of :func:`dataclasses.replace` is positional-only now.