]> granicus.if.org Git - python/commitdiff
bpo-37163: Make the obj argument of dataclasses.replace() a positional-only. (GH...
authorSerhiy Storchaka <storchaka@gmail.com>
Wed, 26 Jun 2019 16:07:44 +0000 (19:07 +0300)
committerGitHub <noreply@github.com>
Wed, 26 Jun 2019 16:07:44 +0000 (19:07 +0300)
Doc/library/dataclasses.rst
Lib/dataclasses.py
Misc/NEWS.d/next/Library/2019-06-19-10-35-53.bpo-37163.9pPg2F.rst [new file with mode: 0644]

index db5c3e0c7e28935357fef5125a73381c6c8ce5c6..9e0288290203ddb7ba141c0dc1d5c356eb6e2163 100644 (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
index b035cbb809f848a29e3d82bcb879e89f1b23c1c2..5e57e200847f0af4aecb2c87cf870562471e602d 100644 (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:
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 (file)
index 0000000..07182e7
--- /dev/null
@@ -0,0 +1 @@
+The *obj* argument of :func:`dataclasses.replace` is positional-only now.