Repository navigation
Conversation
Zarr V3.1 lets an extension definition that needs no configuration be
written as a bare name: `"crc32c"` is equivalent to `{"name": "crc32c"}`.
Reading such a document raised `TypeError: Expected dict, got <class 'str'>`.
`expand_short_hand_name` expands a bare name at the parser of each array
extension point that took only the object form: codecs (including codecs
nested in a sharding codec), chunk_grid, chunk_key_encoding and
storage_transformers. data_type already accepted a bare name. A bare name
for an extension that requires a configuration (`"regular"`, `"gzip"`) is
still rejected, with the missing-configuration error.
Metadata is still written in the object form, which Zarr V3.0 readers
require.
Refs zarr-developers#3188
Assisted-by: ClaudeCode:claude-opus-5-5
Assisted-by: ClaudeCode:claude-opus-5-5
Assisted-by: ClaudeCode:claude-opus-5-5
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4506 +/- ##
==========================================
+ Coverage 94.71% 94.72% +0.01%
==========================================
Files 94 94
Lines 13663 13670 +7
==========================================
+ Hits 12941 12949 +8
+ Misses 722 721 -1
🚀 New features to boost your workflow:
|
d-v-b
marked this pull request as ready for review
October 10, 2026 18:08
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds support for the string shorthand metadata declaration added in the 3.1 revision of the zarr spec
🤖 AI text below 🤖
Read array metadata that uses Zarr V3.1 short-hand extension names, such as
"codecs": ["bytes", "crc32c"]or"chunk_key_encoding": "default". Previously, such documents raisedTypeError: Expected dict, got <class 'str'>. Metadata is still written in the object form that Zarr V3.0 readers require.Refs #3188. Spec compliance fix, intended for a patch release.
Spec
zarr-specs v3 core, "Short-hand names": "Instead of extension objects, short-hand names MAY be used if no configuration metadata is required. They are equivalent to extension objects with just a
namekey."data_type,chunk_grid,chunk_key_encoding, each entry ofcodecs, and each entry ofstorage_transformers"MUST conform to the extension-definition". The note undercodecssays writers that need Zarr v3.0 compatibility must not use the short-hand form, which is why zarr-python keeps writing objects. zarrs changed its writer to always emit objects because zarr-python rejected the short-hand (zarrs/zarrs#488), but other writers may still emit it.Change
A single helper,
zarr.core.common.expand_short_hand_name, turns a bare string into{"name": s}. It runs in the one parser for each extension point:parse_codecs, which also handles thecodecsandindex_codecsnested inside a sharding codec.parse_chunk_key_encoding.parse_chunk_grid. A bare"regular"is still invalid because the grid needs a configuration. It now fails with the missing-configurationValueErrorinstead of aTypeError.parse_storage_transformers. Opening an array that declares storage transformers is still refused.data_typealready accepted a bare name. The publicChunkKeyEncodingLiketype is not widened, socreate_array's signature is unchanged.packages/zarr-metadataalready accepts the short-hand form at every extension point and needs no change.Tests
New cases in
test_array_metadata_roundtripcover:Each case asserts that the object form is written back.
One test per error case:
chunk_grid,gzip,sharding_indexed)The 10 new test cases fail on main and pass with this change. The full suite passes locally without
-W ignore.Not addressed
#3188 also covers
must_understandon extension objects. Currently{"name": "bytes", "must_understand": true}andfalseboth parse silently, and the key is dropped on write. That is left for a separate change, so this PR does not close the issue.Notes
Supersedes the fork draft fix(metadata): read Zarr V3.1 short-hand extension names d-v-b/zarr-python#403 (same branch).
ZEP9: Parse Metadata Objects #2866 (stale since 2025-05) is an earlier, broader attempt at the same issue. It edits each codec's
from_dict.🤖 Generated with Claude Code