Skip to content

fix(zarr-metadata)!: make entity types assignable to metadata fields; validators return tuples - #4378

Merged
d-v-b merged 4 commits into
zarr-developers:mainfrom
d-v-b:zarr-metadata/types-and-tuples
Sep 20, 2026
Merged

d-v-b merged 4 commits into
zarr-developers:mainfrom
d-v-b:zarr-metadata/types-and-tuples

Conversation

@d-v-b

@d-v-b d-v-b commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Part 1 of a split of d-v-b#296 (reviewed on the fork as d-v-b#317). Small and independent; a follow-up PR adding a composition rules layer builds on it.

  • ZarrV3NamedConfigJSON.name / .configuration are ReadOnly (PEP 705) and the envelope is closed (PEP 728), so every concrete codec / chunk-grid / chunk-key-encoding / data-type TypedDict is now assignable to the fields it describes (codecs, chunk_grid, data_type, ...). Previously a type checker rejected putting BloscCodecMetadata into codecs.
  • Every concrete *Object / *Configuration TypedDict is closed, and object forms declare must_understand: NotRequired[bool].
  • Breaking: every validate_* in zarr_metadata.model returns tuple[ValidationProblem, ...] instead of a list, and MetadataValidationError.problems is a tuple.
  • load_store_json returns object rather than Any; ANN401 is enforced package-wide.
  • ZarrV2ConsolidatedMetadataJSON.zarr_consolidated_format is Literal[1].
  • zarr_metadata.pydantic serializers declare their return schema via the pydantic-facing shadow types.

The structural validator is otherwise unchanged; the dimension_names / chunks rank checks stay where they are until part 2.

Rebased onto main. The only conflict was with #4365 (v2 array document is open): its semantics are kept, and its two new tests now expect () from validate_array_metadata_v2.

Verified after rebase: ruff check/format, pyright 1.1.404 (0 errors), 595 package tests.

🤖 Generated with Claude Code

d-v-b and others added 3 commits September 19, 2026 18:52
… validators return tuples

`ZarrV3NamedConfigJSON.name` and `.configuration` are `ReadOnly` and the
envelope is `closed`, so the concrete codec / chunk-grid / chunk-key-encoding
/ data-type TypedDicts are assignable to the fields they describe. Every
concrete `*Object` / `*Configuration` is `closed` and object forms declare
`must_understand: NotRequired[bool]`.

Every `validate_*` in `zarr_metadata.model` returns
`tuple[ValidationProblem, ...]`, `MetadataValidationError.problems` is a
tuple, and `load_store_json` returns `object` rather than `Any`. `ANN401`
is enforced package-wide. `ZarrV2ConsolidatedMetadataJSON.zarr_consolidated_format`
is `Literal[1]`.

Split from #296 (part 1 of 3).

Assisted-by: ClaudeCode:claude-fable-5-1
Assisted-by: ClaudeCode:claude-fable-5-1
…arr-developers#4365's tests

Assisted-by: ClaudeCode:claude-opus-5
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions github-actions Bot added needs release notes Automatically applied to PRs which haven't added release notes zarr-metadata Specific to the zarr-metadata sub-package labels Sep 19, 2026
…4378

Assisted-by: ClaudeCode:claude-opus-5
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@read-the-docs-community

Copy link
Copy Markdown

@d-v-b
d-v-b marked this pull request as ready for review September 20, 2026 08:44
@d-v-b

d-v-b commented Sep 20, 2026

Copy link
Copy Markdown
Contributor Author

this is a zarr-metadata PR that makes a variety of improvements as described in the AI-written PR description. I'm self-merging it.

@d-v-b
d-v-b merged commit ae41d6e into zarr-developers:main Sep 20, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs release notes Automatically applied to PRs which haven't added release notes zarr-metadata Specific to the zarr-metadata sub-package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant