Skip to content

feat(zarr-metadata)!: replace scope update with copy(update=...) and add definitions with union - #427

Draft
d-v-b wants to merge 2 commits into
mainfrom
claude/ecstatic-lamarr-9bd090
Draft

d-v-b wants to merge 2 commits into
mainfrom
claude/ecstatic-lamarr-9bd090

Conversation

@d-v-b

@d-v-b d-v-b commented Oct 29, 2026

Copy link
Copy Markdown
Owner

🤖 AI text below 🤖

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.union(ZarrV3Context(data_types=[MY_DATA_TYPE])), which the docs now show in place of splicing a slot's definitions back in.

Fixes #424.

  • copy's docstring warns that copy(update={"codecs": [X]}) leaves X as the only codec and points at union; the docstrings of union, the scope classes and the definition package overview name union as the way to add definitions.
  • CORE_AND_EXTENSIONS is now built with CORE.union(...). About 50 test call sites moved: splices of a slot's own definitions became union, and replacements by name became copy(update=...).
  • A new test, test_union_adds_definitions_and_keeps_every_one_the_scope_has, covers the case in the issue.
  • The document models (ZarrV3ArrayMetadata and friends) keep their own update(**members), which has the same replace-whole meaning. The agent left them alone, so the two operations now have different names.

just check in packages/zarr-metadata passes: ruff, pyright, the tests on Python 3.11 and the newest supported version, and the strict docs build.

🤖 Generated with Claude Code

d-v-b added 2 commits October 29, 2026 20:08
…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 #424

Assisted-by: ClaudeCode:claude-opus-5-5
…ts PR

Assisted-by: ClaudeCode:claude-opus-5-5

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zarr-metadata: Scope.update() replaces slots whole; adding a definition can silently drop the defaults

1 participant