Skip to content

fix![zarr-metadata]: define JSONValue type, and narrow object annotations to use JSONValue#4037

Merged
d-v-b merged 16 commits into
zarr-developers:mainfrom
d-v-b:json-in-zarr-metadata
Jun 12, 2026
Merged

fix![zarr-metadata]: define JSONValue type, and narrow object annotations to use JSONValue#4037
d-v-b merged 16 commits into
zarr-developers:mainfrom
d-v-b:json-in-zarr-metadata

Conversation

@d-v-b

@d-v-b d-v-b commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

This defines a JSONValue type that models python objects that easily become JSON. To be clear, json.loads is still essentially untyped, so this JSONValue type requires type narrowing when you read actual JSON data. But for constructing values that will fit into JSON, this is a useful type and necessary for modelling e.g. the fill_value field of array metadata documents, which previously were object, and that's far too open.

Happy to be bikeshedded on the name of the type -- JSON or JSONValue. I think JSONValue is more accurate, since JSON can denote a file or a bytestream or the format.

This is a breaking change to zarr-metadata, so it needs a minor version bump (e.g., to 0.3.0) when we issue our next release of the package.

dependabot Bot and others added 3 commits May 31, 2026 19:28
…#176)

Bumps the actions group with 8 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [prefix-dev/setup-pixi](https://github.com/prefix-dev/setup-pixi) | `0.9.5` | `0.9.6` |
| [codecov/codecov-action](https://github.com/codecov/codecov-action) | `6.0.0` | `6.0.1` |
| [github/issue-metrics](https://github.com/github/issue-metrics) | `4.2.2` | `4.2.7` |
| [j178/prek-action](https://github.com/j178/prek-action) | `2.0.3` | `2.0.4` |
| [actions/upload-artifact](https://github.com/actions/upload-artifact) | `7.0.0` | `7.0.1` |
| [actions/download-artifact](https://github.com/actions/download-artifact) | `7.0.0` | `8.0.1` |
| [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) | `1.13.0` | `1.14.0` |
| [zizmorcore/zizmor-action](https://github.com/zizmorcore/zizmor-action) | `0.5.3` | `0.5.6` |



Updates `prefix-dev/setup-pixi` from 0.9.5 to 0.9.6
- [Release notes](https://github.com/prefix-dev/setup-pixi/releases)
- [Commits](prefix-dev/setup-pixi@1b2de7f...5185adf)

Updates `codecov/codecov-action` from 6.0.0 to 6.0.1
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](codecov/codecov-action@57e3a13...e79a696)

Updates `github/issue-metrics` from 4.2.2 to 4.2.7
- [Release notes](https://github.com/github/issue-metrics/releases)
- [Commits](github-community-projects/issue-metrics@c9e9838...1e38d5e)

Updates `j178/prek-action` from 2.0.3 to 2.0.4
- [Release notes](https://github.com/j178/prek-action/releases)
- [Commits](j178/prek-action@6ad8027...bdca6f1)

Updates `actions/upload-artifact` from 7.0.0 to 7.0.1
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@v7...043fb46)

Updates `actions/download-artifact` from 7.0.0 to 8.0.1
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](actions/download-artifact@v7...3e5f45b)

Updates `pypa/gh-action-pypi-publish` from 1.13.0 to 1.14.0
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@v1.13.0...cef2210)

Updates `zizmorcore/zizmor-action` from 0.5.3 to 0.5.6
- [Release notes](https://github.com/zizmorcore/zizmor-action/releases)
- [Commits](zizmorcore/zizmor-action@b1d7e1f...5f14fd0)

---
updated-dependencies:
- dependency-name: prefix-dev/setup-pixi
  dependency-version: 0.9.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: codecov/codecov-action
  dependency-version: 6.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: github/issue-metrics
  dependency-version: 4.2.7
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: j178/prek-action
  dependency-version: 2.0.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: actions/upload-artifact
  dependency-version: 7.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: actions/download-artifact
  dependency-version: 8.0.1
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: pypa/gh-action-pypi-publish
  dependency-version: 1.14.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
- dependency-name: zizmorcore/zizmor-action
  dependency-version: 0.5.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@github-actions github-actions Bot added the needs release notes Automatically applied to PRs which haven't added release notes label Jun 4, 2026
@d-v-b d-v-b requested a review from mkitti June 4, 2026 16:28
@mkitti mkitti requested a review from Copilot June 5, 2026 20:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens the typing surface of zarr-metadata by introducing a recursive JSONValue type and using it to replace overly-broad object annotations in v2/v3 metadata TypedDicts (notably fill_value, attributes, and extension/configuration fields). It also narrows the struct field data_type to the existing MetadataFieldV3 union.

Changes:

  • Add JSONValue (recursive JSON-encodable value type) and apply it across v2/v3 metadata schemas in place of object.
  • Narrow several schema fields to domain-specific types (e.g., StructField.data_type -> MetadataFieldV3).
  • Add a .claude hook log file to the repository (likely unintended for source control).

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/zarr-metadata/src/zarr_metadata/_common.py Introduces JSONValue and uses it for NamedConfig.configuration.
packages/zarr-metadata/src/zarr_metadata/v3/array.py Replaces object with JSONValue for fill_value, attributes, and v3 extension extra-items.
packages/zarr-metadata/src/zarr_metadata/v3/group.py Narrows v3 group attributes to Mapping[str, JSONValue].
packages/zarr-metadata/src/zarr_metadata/v3/data_type/struct.py Narrows StructField.data_type to MetadataFieldV3 and StructFillValue to JSONValue.
packages/zarr-metadata/src/zarr_metadata/v3/codec/scale_offset.py Narrows offset/scale config fields to JSONValue.
packages/zarr-metadata/src/zarr_metadata/v3/codec/cast_value.py Narrows scalar_map entries to tuple[JSONValue, JSONValue].
packages/zarr-metadata/src/zarr_metadata/v2/array.py Narrows v2 array fill_value and merged attributes to JSONValue.
packages/zarr-metadata/src/zarr_metadata/v2/group.py Narrows v2 group merged attributes to JSONValue.
packages/zarr-metadata/src/zarr_metadata/v2/codec.py Narrows v2 codec extra-items to JSONValue.
packages/zarr-metadata/src/zarr_metadata/v2/attributes.py Narrows .zattrs content to Mapping[str, JSONValue].
packages/zarr-metadata/.claude/hooks/.logs/hook-log.jsonl Adds a hook execution log entry to the repo.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/zarr-metadata/src/zarr_metadata/_common.py
Comment thread packages/zarr-metadata/src/zarr_metadata/_common.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Comment thread packages/zarr-metadata/src/zarr_metadata/__init__.py
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.53%. Comparing base (205f5f8) to head (1e59b87).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4037   +/-   ##
=======================================
  Coverage   93.53%   93.53%           
=======================================
  Files          89       89           
  Lines       11901    11901           
=======================================
  Hits        11132    11132           
  Misses        769      769           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@d-v-b d-v-b enabled auto-merge (squash) June 12, 2026 09:32
@d-v-b d-v-b merged commit 97d781b into zarr-developers:main Jun 12, 2026
37 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants