diff options
author | Zackery Spytz <zspytz@gmail.com> | 2021-04-05 19:41:01 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-05 19:41:01 (GMT) |
commit | 75220674c07abfc90c2cd7862d04cfa2e2354450 (patch) | |
tree | 7da8600bce2e46bd148120f8dc5044946fb6385a /Lib/dataclasses.py | |
parent | 14829b09eb652f457cf837836909169746a810f0 (diff) | |
download | cpython-75220674c07abfc90c2cd7862d04cfa2e2354450.zip cpython-75220674c07abfc90c2cd7862d04cfa2e2354450.tar.gz cpython-75220674c07abfc90c2cd7862d04cfa2e2354450.tar.bz2 |
bpo-36470: Allow dataclasses.replace() to handle InitVars with default values (GH-20867)
Co-Authored-By: Claudiu Popa <pcmanticore@gmail.com>
Automerge-Triggered-By: GH:ericvsmith
Diffstat (limited to 'Lib/dataclasses.py')
-rw-r--r-- | Lib/dataclasses.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/dataclasses.py b/Lib/dataclasses.py index 422a95c..3de2ec0 100644 --- a/Lib/dataclasses.py +++ b/Lib/dataclasses.py @@ -1300,7 +1300,7 @@ def replace(obj, /, **changes): continue if f.name not in changes: - if f._field_type is _FIELD_INITVAR: + if f._field_type is _FIELD_INITVAR and f.default is MISSING: raise ValueError(f"InitVar {f.name!r} " 'must be specified with replace()') changes[f.name] = getattr(obj, f.name) |