Repository navigation
Conversation
…initions A data type defined outside the package could annotate its fill value as `Base64Bytes`, but that is a `NewType` of `str`, so any string passed unless the definition also wrote its own base64 check in `fill_value_rules`. The package's rule was private, and the guides never mentioned `fill_value_rules`. `base64_fill_value_rules` is now public in `zarr_metadata.v3.data_type.bytes`. It fits the `fill_value_rules` slot, checks only strings, and is the one base64 check that `bytes`, `variable_length_bytes`, `null_terminated_bytes` and v2's sized base64 rule all use. The parsing-validation guide shows a data type whose rule yields from it and then checks the size its configuration sets. Refs #425 Assisted-by: ClaudeCode:claude-opus-5-5
Assisted-by: ClaudeCode:claude-opus-5-5
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.
🤖 AI text below 🤖
Export
base64_fill_value_rulesfromzarr_metadata.v3.data_type.bytes, the rule that rejects a fill value string that is not standard-alphabet base64, so a data type defined outside the package can pass it asfill_value_rulesfor aBase64Bytesfill value, or yield from it in a rule of its own. The guide to parsing and validation now shows how to define a data type withfill_value_rules.Refs #425. The issue asks for a way to constrain a fill value beyond its JSON type.
fill_value_rulesalready does that, and both the reader and the pydantic field apply it. The consumer's definition only setfill_value=str, the guides never mentionedfill_value_rules, and the package's base64 rule was private. This PR fixes the last two.base64_fill_value_rules(in_numpy.py) fits thefill_value_rulesslot and checks only strings, so it also servesbytes, whose fill value may be written as byte values. It replaces every other copy of the check:bytes,variable_length_bytes,null_terminated_bytesand v2'ssized_base64_rules.docs/parsing-validation.mdgains an example: anacme.packeddata type whose rule yields frombase64_fill_value_rulesand then checks the size its configuration sets. The example runs in the docs tests.json_schemamodule documents, so a schema for such a scope accepts any string. Carrying a format into the schema would need string-pattern constraints in the type checker. That is not part of this PR.Stack
Stacked on #426 (the
ZARR_PYTHON_CONTEXTscope, which addsnull_terminated_bytesandvariable_length_bytes), and based on its branchclaude/zarr-python-scope-a042b7. Merge #426 first. Then retarget this PR tomain.🤖 Generated with Claude Code