Skip to content

Commit 94dcfd1

Browse files
authored
feat(zarr-metadata)!: replace scope update with copy(update=...) and add definitions with union (zarr-developers#4598)
* feat(zarr-metadata)!: replace scope update with copy(update=...) and add definitions with union `ZarrV3Context.update(**slots)` and `ZarrV2Context.update(**slots)` read as a merge, but replace each slot whole, so passing one new definition silently dropped every default. They become `copy(*, update=None)`, after pydantic's `model_copy(update=...)`, whose replace-whole meaning pydantic users already know. Adding definitions is `union`, which keeps every definition the scope has and refuses a conflicting one; the docs, docstrings and call sites now use it instead of splicing a slot's definitions back in. Fixes zarr-developers#424 Assisted-by: ClaudeCode:claude-opus-5-5 * docs(zarr-metadata): number the scope copy changelog fragment after its PR Assisted-by: ClaudeCode:claude-opus-5-5 * test(zarr-metadata): check copy refuses another format's definition and name copy in scope docstrings Assisted-by: ClaudeCode:claude-opus-5-5
1 parent 630bf36 commit 94dcfd1

29 files changed

Lines changed: 259 additions & 231 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Replace `ZarrV3Context.update(**slots)` and `ZarrV2Context.update(**slots)` with `copy(*, update=None)`, after pydantic's `model_copy(update=...)`: `context.update(codecs=[...])` becomes `context.copy(update={"codecs": [...]})`, and still replaces each slot it is given whole. To add definitions to a scope and keep the ones it has, use `union`: `CORE_AND_EXTENSIONS_CONTEXT.union(ZarrV3Context(data_types=[MY_DATA_TYPE]))`, which the docs now show in place of splicing a slot's definitions back in.

‎packages/zarr-metadata/docs/context.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ In this example, our context object only contained one codec definition, for the
7373
After resolution the `gzip` codec was explicitly flagged as unrecognized. But we can actually check that codec declaration against a real codec definition by expanding our context to include the `GZIP_CODEC` definition:
7474

7575
```python test="true" session="context"
76-
new_context = context.update(codecs={**context.codecs, "gzip": GZIP_CODEC})
76+
new_context = context.union(ZarrV3Context(codecs=[GZIP_CODEC]))
7777
```
7878

79-
`update` returns a new context with the `codecs` slot replaced. We pass the codecs the old context already has, plus `gzip`, so the new context claims both `bytes` and `gzip`. The old context is unchanged.
79+
`union` returns a new context that files every definition of both, so the new context claims both `bytes` and `gzip`. The old context is unchanged. To replace a slot instead of adding to it, use `copy(update=...)`.
8080

8181
Now read the same document in the new context. `read_array_metadata_v3` returns everything the read found, instead of raising, so we can look at each codec:
8282

‎packages/zarr-metadata/docs/parsing-validation.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,17 @@ To make an unknown data type or codec known, add its definition to the scope's s
214214

215215
```python test="true" session="parsing-validation"
216216
from zarr_metadata.definition import EmptyConfiguration
217-
from zarr_metadata.v3.definition import CORE_AND_EXTENSIONS_CONTEXT, CodecDefinition
217+
from zarr_metadata.v3.definition import CORE_AND_EXTENSIONS_CONTEXT, CodecDefinition, ZarrV3Context
218218

219219
# The definition of the codec that was unknown: here, a codec named
220220
# `acme.codec` that takes no configuration.
221221
MY_CODEC = CodecDefinition(
222222
name="acme.codec", configuration=EmptyConfiguration, kind="bytes_bytes", size="dynamic"
223223
)
224-
context = CORE_AND_EXTENSIONS_CONTEXT.update(codecs=[*CORE_AND_EXTENSIONS_CONTEXT.codecs.values(), MY_CODEC])
224+
context = CORE_AND_EXTENSIONS_CONTEXT.union(ZarrV3Context(codecs=[MY_CODEC]))
225225
reading = read_array_metadata_v3(raw, context=context)
226226
```
227227

228-
`update` replaces each slot it is given and keeps the others. A slot can also be given as a mapping from each definition's name to it, so `CORE_AND_EXTENSIONS_CONTEXT.update(codecs={**CORE_AND_EXTENSIONS_CONTEXT.codecs, "gzip": MY_GZIP})` replaces the gzip definition with your own.
228+
`union` keeps every definition the scope has, and raises `ScopeConflictError` if `MY_CODEC` has a name the scope already files with another definition. To replace a definition on purpose, use `copy`, which, like pydantic's `model_copy(update=...)`, replaces whole each slot it is given and keeps the others. A slot can be given as a mapping from each definition's name to it, so `CORE_AND_EXTENSIONS_CONTEXT.copy(update={"codecs": {**CORE_AND_EXTENSIONS_CONTEXT.codecs, "gzip": MY_GZIP}})` replaces the gzip definition with your own. Passing `copy(update={"codecs": [MY_CODEC]})` instead would leave `MY_CODEC` as the only codec.
229229

230230
[^1]: The one exception is the `r*` data type, which is identified by a templated string with no `configuration` object. This mixes the identifier with the configuration in the same JSON value, which is not good design. So this library normalizes `r*` into the same form as all the other metadata objects: the declaration `"r16"` keeps its name, and is read by the `r*` definition with the configuration `{"bits": 16}`.

‎packages/zarr-metadata/src/zarr_metadata/definition/__init__.py‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
125125
from zarr_metadata import ValidationProblem
126126
from zarr_metadata.definition import Nested
127-
from zarr_metadata.v3.definition import CORE_AND_EXTENSIONS_CONTEXT, CodecDefinition
127+
from zarr_metadata.v3.definition import CORE_AND_EXTENSIONS_CONTEXT, CodecDefinition, ZarrV3Context
128128
129129
130130
class AcmeLz4Configuration(TypedDict, closed=True):
@@ -149,7 +149,7 @@ def acme_lz4_rules(
149149
size="dynamic",
150150
rules=acme_lz4_rules,
151151
)
152-
CONTEXT = CORE_AND_EXTENSIONS_CONTEXT.update(codecs=[*CORE_AND_EXTENSIONS_CONTEXT.codecs.values(), ACME_LZ4])
152+
CONTEXT = CORE_AND_EXTENSIONS_CONTEXT.union(ZarrV3Context(codecs=[ACME_LZ4]))
153153
154154
The TypedDict declares how keys it does not declare are handled. With
155155
`closed=True`, such a key is a problem, as above. With `extra_items=`,
@@ -231,11 +231,12 @@ def acme_lz4_rules(
231231
format and file the same definitions, and equal scopes have equal
232232
hashes. `context.union(*others)` returns the smallest scope that
233233
contains each of them, or raises a `ScopeConflictError` naming each name
234-
filed with two different definitions. `update` replaces the
235-
definitions in the slots it is given and keeps the others, and takes a
236-
slot as definitions or as a mapping by name, so
237-
`context.update(codecs={**context.codecs, "gzip": MY_GZIP})` replaces
238-
one definition on purpose. A model's `refined_in` moves it to a scope
234+
filed with two different definitions. It is how to add definitions to a
235+
scope, keeping the ones it has. `context.copy(update={...})`, like
236+
pydantic's `model_copy`, replaces whole each slot it is given and keeps
237+
the others. It takes a slot as definitions or as a mapping by name, so
238+
`context.copy(update={"codecs": {**context.codecs, "gzip": MY_GZIP}})`
239+
replaces one definition on purpose. A model's `refined_in` moves it to a scope
239240
that claims more names and contradicts nothing. `refines` orders two
240241
models by how much they know. A name that was unclaimed and is now read
241242
by a definition is a gain. The reverse is a loss. One name read by two

‎packages/zarr-metadata/src/zarr_metadata/v2/_context.py‎

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def is_v2_kind(kind: type[Definition[Any]]) -> TypeIs[type[ZarrV2Kind]]:
5151

5252

5353
class ZarrV2ContextSlots(TypedDict, total=False, closed=True):
54-
"""The definitions in each slot of a v2 scope, as `ZarrV2Context` and its `update` take them.
54+
"""The definitions in each slot of a v2 scope, as `ZarrV2Context` and its `copy` take them.
5555
5656
This is where a v2 scope's slots are declared: each key is a slot,
5757
and its value the definitions of the kind that slot holds, as an
@@ -77,13 +77,13 @@ class ZarrV2Context:
7777
document holds, as `ZarrV2ContextSlots` declares them: `data_types`,
7878
read from `dtype`, and `codecs`, read from `compressor` and `filters`.
7979
Each slot is a read-only mapping from name to definition. The
80-
constructor and `update` take, for each slot, an iterable of
80+
constructor and `copy` take, for each slot, an iterable of
8181
definitions or such a mapping, so one scope's slot can be given to
8282
another. A definition of another kind than its slot holds, and a key
8383
that is not its definition's name, raise `TypeError`, and two
8484
different definitions under one name in a slot raise
85-
`ScopeConflictError`. To replace a definition, or a whole slot, use
86-
`update`.
85+
`ScopeConflictError`. To add definitions, use `union`. To replace a
86+
definition, or a whole slot, use `copy`.
8787
`ZarrV2Context()` is the scope that claims nothing. Two scopes are
8888
equal when they file the same definitions in each slot, and equal
8989
scopes have equal hashes.
@@ -139,26 +139,28 @@ def claimant(self, kind: type[D], name: str) -> D | None:
139139
"""
140140
return claimant_in(self._tables, kind, name)
141141

142-
def update(self, **slots: Unpack[ZarrV2ContextSlots]) -> ZarrV2Context:
143-
"""This scope, with each slot given here holding only the definitions given for it. The other slots are kept.
142+
def copy(self, *, update: ZarrV2ContextSlots | None = None) -> ZarrV2Context:
143+
"""This scope, with each slot in `update` holding only the definitions given for it, as pydantic's `model_copy(update=...)` replaces each field it is given. The other slots are kept.
144144
145-
A slot can be given as a mapping from each definition's name to
146-
it, so a slot of this scope passes back in changed:
147-
`context.update(codecs={**context.codecs, "gzip": MY_GZIP})`
148-
replaces the gzip definition and keeps the other codecs, and
149-
`context.update(codecs=[*context.codecs.values(), MY_CODEC])` adds
150-
one, raising `ScopeConflictError` if the scope already files
151-
another definition under its name.
145+
A slot given here is replaced whole: `context.copy(update={"codecs": [MY_CODEC]})`
146+
is a scope whose only codec is `MY_CODEC`. To add definitions to a
147+
scope, use `union`: `context.union(ZarrV2Context(codecs=[MY_CODEC]))`.
148+
A slot can be given as a mapping from each definition's name to it,
149+
so a slot of this scope passes back in changed:
150+
`context.copy(update={"codecs": {**context.codecs, "gzip": MY_GZIP}})`
151+
replaces the gzip definition and keeps the other codecs.
152152
"""
153-
return self._of(updated(self._tables, self.kinds, slots, 2))
153+
return self._of(updated(self._tables, self.kinds, {} if update is None else update, 2))
154154

155155
def union(self, *others: ZarrV2Context) -> ZarrV2Context:
156156
"""The smallest scope that files everything this scope and each of `others` file.
157157
158-
Raises `ScopeConflictError` when two of them file different
159-
definitions under one name in a slot. To replace a definition on
160-
purpose, use `update`. Raises `TypeError` for a scope of another
161-
format.
158+
This is how to add definitions to a scope:
159+
`CORE_V2_CONTEXT.union(ZarrV2Context(codecs=[MY_CODEC]))` keeps every
160+
definition of `CORE_V2_CONTEXT` and adds `MY_CODEC`. Raises
161+
`ScopeConflictError` when two of them file different definitions
162+
under one name in a slot. To replace a definition on purpose, use
163+
`copy`. Raises `TypeError` for a scope of another format.
162164
"""
163165
refuse_others(others, ZarrV2Context)
164166
return self._of(

‎packages/zarr-metadata/src/zarr_metadata/v2/definition.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
`resolve("<f4", ZarrV2DataTypeDefinition, CORE_V2_CONTEXT)` returns an
1111
`AcceptedDeclaration`, `UnclaimedDeclaration` or `RefusedDeclaration`, and every problem.
1212
`ZarrV2Context` is the class of a v2 scope. It has a slot for each kind
13-
of v2 declaration, `data_types` and `codecs`, and shares `update`,
13+
of v2 declaration, `data_types` and `codecs`, and shares `copy`,
1414
`union` and `claimant` with the v3 scope. A v2 reader rejects a v3
1515
scope with `TypeError`.
1616

‎packages/zarr-metadata/src/zarr_metadata/v3/_context.py‎

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def is_v3_kind(kind: type[Definition[Any]]) -> TypeIs[type[ZarrV3Kind]]:
6767

6868

6969
class ZarrV3ContextSlots(TypedDict, total=False, closed=True):
70-
"""The definitions in each slot of a v3 scope, as `ZarrV3Context` and its `update` take them.
70+
"""The definitions in each slot of a v3 scope, as `ZarrV3Context` and its `copy` take them.
7171
7272
This is where a v3 scope's slots are declared: each key is a slot,
7373
and its value the definitions of the kind that slot holds, as an
@@ -114,13 +114,13 @@ class ZarrV3Context:
114114
`group_extra_fields` hold the definitions of members the spec does not
115115
define, by key. Each slot is a read-only mapping from the name each
116116
definition is filed under (`r*` for raw bits) to the definition. The
117-
constructor and `update` take, for each slot, an iterable of
117+
constructor and `copy` take, for each slot, an iterable of
118118
definitions or such a mapping, so one scope's slot can be given to
119119
another. A definition of another kind than its slot holds, and a key
120120
that is not its definition's name, raise `TypeError`, and two
121121
different definitions under one name in a slot raise
122-
`ScopeConflictError`. To replace a definition, or a whole slot, use
123-
`update`.
122+
`ScopeConflictError`. To add definitions, use `union`. To replace a
123+
definition, or a whole slot, use `copy`.
124124
`ZarrV3Context()` is the scope that claims nothing. Two scopes are
125125
equal when they file the same definitions in each slot, and equal
126126
scopes have equal hashes.
@@ -201,26 +201,28 @@ def claimant(self, kind: type[D], name: str) -> D | None:
201201
"""
202202
return claimant_in(self._tables, kind, name)
203203

204-
def update(self, **slots: Unpack[ZarrV3ContextSlots]) -> ZarrV3Context:
205-
"""This scope, with each slot given here holding only the definitions given for it. The other slots are kept.
204+
def copy(self, *, update: ZarrV3ContextSlots | None = None) -> ZarrV3Context:
205+
"""This scope, with each slot in `update` holding only the definitions given for it, as pydantic's `model_copy(update=...)` replaces each field it is given. The other slots are kept.
206206
207-
A slot can be given as a mapping from each definition's name to
208-
it, so a slot of this scope passes back in changed:
209-
`context.update(codecs={**context.codecs, "gzip": MY_GZIP})`
210-
replaces the gzip definition and keeps the other codecs, and
211-
`context.update(codecs=[*context.codecs.values(), MY_CODEC])` adds
212-
one, raising `ScopeConflictError` if the scope already files
213-
another definition under its name.
207+
A slot given here is replaced whole: `context.copy(update={"codecs": [MY_CODEC]})`
208+
is a scope whose only codec is `MY_CODEC`. To add definitions to a
209+
scope, use `union`: `context.union(ZarrV3Context(codecs=[MY_CODEC]))`.
210+
A slot can be given as a mapping from each definition's name to it,
211+
so a slot of this scope passes back in changed:
212+
`context.copy(update={"codecs": {**context.codecs, "gzip": MY_GZIP}})`
213+
replaces the gzip definition and keeps the other codecs.
214214
"""
215-
return self._of(updated(self._tables, self.kinds, slots, 3))
215+
return self._of(updated(self._tables, self.kinds, {} if update is None else update, 3))
216216

217217
def union(self, *others: ZarrV3Context) -> ZarrV3Context:
218218
"""The smallest scope that files everything this scope and each of `others` file.
219219
220-
Raises `ScopeConflictError` when two of them file different
221-
definitions under one name in a slot. To replace a definition on
222-
purpose, use `update`. Raises `TypeError` for a scope of another
223-
format.
220+
This is how to add definitions to a scope:
221+
`CORE_AND_EXTENSIONS_CONTEXT.union(ZarrV3Context(codecs=[MY_CODEC]))` keeps every
222+
definition of `CORE_AND_EXTENSIONS_CONTEXT` and adds `MY_CODEC`. Raises
223+
`ScopeConflictError` when two of them file different definitions
224+
under one name in a slot. To replace a definition on purpose, use
225+
`copy`. Raises `TypeError` for a scope of another format.
224226
"""
225227
refuse_others(others, ZarrV3Context)
226228
return self._of(

‎packages/zarr-metadata/src/zarr_metadata/v3/_core.py‎

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -88,35 +88,36 @@
8888
)
8989
"""A scope with only what the Zarr v3 specification defines, including the envelope of a group's `consolidated_metadata`, which the spec fixes."""
9090

91-
CORE_AND_EXTENSIONS_CONTEXT: Final = CORE_CONTEXT.update(
92-
data_types=[
93-
*CORE_CONTEXT.data_types.values(),
94-
BYTES_DATA_TYPE,
95-
STRING_DATA_TYPE,
96-
FIXED_LENGTH_UTF32_DATA_TYPE,
97-
NUMPY_DATETIME64_DATA_TYPE,
98-
NUMPY_TIMEDELTA64_DATA_TYPE,
99-
STRUCT_DATA_TYPE,
100-
],
101-
chunk_grids=[*CORE_CONTEXT.chunk_grids.values(), RECTILINEAR_CHUNK_GRID],
102-
codecs=[
103-
*CORE_CONTEXT.codecs.values(),
104-
CAST_VALUE_CODEC,
105-
SCALE_OFFSET_CODEC,
106-
VLEN_BYTES_CODEC,
107-
VLEN_UTF8_CODEC,
108-
ZSTD_CODEC,
109-
],
91+
CORE_AND_EXTENSIONS_CONTEXT: Final = CORE_CONTEXT.union(
92+
ZarrV3Context(
93+
data_types=[
94+
BYTES_DATA_TYPE,
95+
STRING_DATA_TYPE,
96+
FIXED_LENGTH_UTF32_DATA_TYPE,
97+
NUMPY_DATETIME64_DATA_TYPE,
98+
NUMPY_TIMEDELTA64_DATA_TYPE,
99+
STRUCT_DATA_TYPE,
100+
],
101+
chunk_grids=[RECTILINEAR_CHUNK_GRID],
102+
codecs=[
103+
CAST_VALUE_CODEC,
104+
SCALE_OFFSET_CODEC,
105+
VLEN_BYTES_CODEC,
106+
VLEN_UTF8_CODEC,
107+
ZSTD_CODEC,
108+
],
109+
)
110110
)
111111
"""A scope with what the specification defines, plus the extensions that `zarr-extensions` registers and this package defines."""
112112

113-
ZARR_PYTHON_CONTEXT: Final = CORE_AND_EXTENSIONS_CONTEXT.update(
114-
data_types=[
115-
*CORE_AND_EXTENSIONS_CONTEXT.data_types.values(),
116-
NULL_TERMINATED_BYTES_DATA_TYPE,
117-
VARIABLE_LENGTH_BYTES_DATA_TYPE,
118-
ZARR_PYTHON_RAW_BYTES_DATA_TYPE,
119-
],
113+
ZARR_PYTHON_CONTEXT: Final = CORE_AND_EXTENSIONS_CONTEXT.union(
114+
ZarrV3Context(
115+
data_types=[
116+
NULL_TERMINATED_BYTES_DATA_TYPE,
117+
VARIABLE_LENGTH_BYTES_DATA_TYPE,
118+
ZARR_PYTHON_RAW_BYTES_DATA_TYPE,
119+
]
120+
)
120121
)
121122
"""A scope with `CORE_AND_EXTENSIONS_CONTEXT`, plus the data types that zarr-python writes but no specification registers: `null_terminated_bytes`, `variable_length_bytes` and `raw_bytes`.
122123

‎packages/zarr-metadata/tests/model/test_consolidating.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
MY_BYTES = CodecDefinition(
4242
name="bytes", configuration=EmptyConfiguration, kind="array_bytes", size="static"
4343
)
44-
PRIVATE = CORE_CONTEXT.update(codecs={**CORE_CONTEXT.codecs, "bytes": MY_BYTES})
44+
PRIVATE = CORE_CONTEXT.copy(update={"codecs": {**CORE_CONTEXT.codecs, "bytes": MY_BYTES}})
4545
INLINE: dict[str, Any] = {"kind": "inline", "must_understand": False}
4646

4747

@@ -315,7 +315,7 @@ def test_error_a_data_type_conflict_names_the_kind_and_the_written_name() -> Non
315315
)
316316
child = ZarrV3ArrayMetadata(
317317
{**ARRAY, "data_type": "r16", "fill_value": [0, 0], "codecs": ("bytes",)},
318-
context=CORE_CONTEXT.update(data_types={**CORE_CONTEXT.data_types, "r*": strict}),
318+
context=CORE_CONTEXT.copy(update={"data_types": {**CORE_CONTEXT.data_types, "r*": strict}}),
319319
)
320320
with pytest.raises(MetadataValidationError) as raised:
321321
_consolidated(CORE_CONTEXT, a=child)
@@ -333,7 +333,7 @@ def test_error_a_conflict_between_definitions_alike_says_they_differ() -> None:
333333
strict = dataclasses.replace(GZIP_CODEC, rules=lambda configuration, nested: iter(()))
334334
child = ZarrV3ArrayMetadata(
335335
{**ARRAY, "codecs": ("bytes", {"name": "gzip", "configuration": {"level": 1}})},
336-
context=CORE_CONTEXT.update(codecs={**CORE_CONTEXT.codecs, "gzip": strict}),
336+
context=CORE_CONTEXT.copy(update={"codecs": {**CORE_CONTEXT.codecs, "gzip": strict}}),
337337
)
338338
with pytest.raises(MetadataValidationError) as raised:
339339
_consolidated(CORE_CONTEXT, a=child)

‎packages/zarr-metadata/tests/model/test_construction.py‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ def counted(
195195
yield from ()
196196

197197
counting = dataclasses.replace(INT8_DATA_TYPE, fill_value_rules=counted)
198-
context = CORE_AND_EXTENSIONS_CONTEXT.update(
199-
data_types={**CORE_AND_EXTENSIONS_CONTEXT.data_types, "int8": counting}
198+
context = CORE_AND_EXTENSIONS_CONTEXT.copy(
199+
update={"data_types": {**CORE_AND_EXTENSIONS_CONTEXT.data_types, "int8": counting}}
200200
)
201201
model = ZarrV3ArrayMetadata.create_default(context=context, data_type="int8", fill_value=3)
202202
assert values == [3]
@@ -458,10 +458,12 @@ def counting(configuration: GzipCodecConfiguration) -> GzipCodecConfiguration:
458458
asked.append(1)
459459
return configuration
460460

461-
context = CORE_AND_EXTENSIONS_CONTEXT.update(
462-
codecs={
463-
**CORE_AND_EXTENSIONS_CONTEXT.codecs,
464-
"gzip": dataclasses.replace(GZIP_CODEC, canonical=counting),
461+
context = CORE_AND_EXTENSIONS_CONTEXT.copy(
462+
update={
463+
"codecs": {
464+
**CORE_AND_EXTENSIONS_CONTEXT.codecs,
465+
"gzip": dataclasses.replace(GZIP_CODEC, canonical=counting),
466+
}
465467
}
466468
)
467469
document = {
@@ -491,10 +493,12 @@ def test_error_a_canonical_that_raises_is_raised_when_the_model_is_first_compare
491493
def refuses(configuration: GzipCodecConfiguration) -> GzipCodecConfiguration:
492494
raise ValueError("no")
493495

494-
context = CORE_AND_EXTENSIONS_CONTEXT.update(
495-
codecs={
496-
**CORE_AND_EXTENSIONS_CONTEXT.codecs,
497-
"gzip": dataclasses.replace(GZIP_CODEC, canonical=refuses),
496+
context = CORE_AND_EXTENSIONS_CONTEXT.copy(
497+
update={
498+
"codecs": {
499+
**CORE_AND_EXTENSIONS_CONTEXT.codecs,
500+
"gzip": dataclasses.replace(GZIP_CODEC, canonical=refuses),
501+
}
498502
}
499503
)
500504
document = {

0 commit comments

Comments
 (0)