feat: Improved type hinting using zarr-metadata#38
Merged
Conversation
kylebarron
commented
Jun 22, 2026
| @staticmethod | ||
| def from_config(config: dict[str, Any]) -> Crc32c: | ||
| """Construct a `crc32c` codec from a configuration mapping, e.g. `{}`.""" | ||
| def from_config(config: Mapping[str, JSONValue]) -> Crc32c: |
Member
Author
There was a problem hiding this comment.
Here can we have a typedDict config that is... empty? To force a {} type if anything is provided? Maybe on the rust side we can default to {}
kylebarron
commented
Jun 22, 2026
| """The ordered chain of codecs used to encode and decode an array's chunks.""" | ||
|
|
||
| def __init__(self, metadatas: list[dict[str, Any]]) -> None: | ||
| def __init__(self, metadatas: list[MetadataV3]) -> None: |
Member
Author
There was a problem hiding this comment.
this list should probably be Sequence
kylebarron
commented
Jun 22, 2026
Comment on lines
-32
to
-52
| DataTypeName: TypeAlias = Literal[ | ||
| "bool", | ||
| "int8", | ||
| "int16", | ||
| "int32", | ||
| "int64", | ||
| "uint8", | ||
| "uint16", | ||
| "uint32", | ||
| "uint64", | ||
| "float16", | ||
| "float32", | ||
| "float64", | ||
| "complex64", | ||
| "complex128", | ||
| "string", | ||
| "bytes", | ||
| ] | ||
| """The Zarr v3 names of the built-in fixed data types. | ||
| """ | ||
|
|
Member
Author
There was a problem hiding this comment.
Ideally upstream zarr-metadata will add its own type union, cc @d-v-b
kylebarron
commented
Jun 22, 2026
Comment on lines
+24
to
+46
| DataTypeName: TypeAlias = ( | ||
| BoolDataTypeName | ||
| | Int8DataTypeName | ||
| | Int16DataTypeName | ||
| | Int32DataTypeName | ||
| | Int64DataTypeName | ||
| | Uint8DataTypeName | ||
| | Uint16DataTypeName | ||
| | Uint32DataTypeName | ||
| | Uint64DataTypeName | ||
| | Float16DataTypeName | ||
| | Float32DataTypeName | ||
| | Float64DataTypeName | ||
| | Complex64DataTypeName | ||
| | Complex128DataTypeName | ||
| | StringDataTypeName | ||
| | BytesDataTypeName | ||
| | RawBytesDataTypeName | ||
| ) | ||
| """The Zarr v3 names of the data types `from_string` can build. | ||
|
|
||
| Composed from the per-dtype name literals in `zarr_metadata.v3.data_type`, so | ||
| it stays in sync with the spec rather than being hand-maintained here. |
Member
Author
There was a problem hiding this comment.
For now we define our own explicit dtype union, cc @d-v-b
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.
Change list
Zstdcodec now has afrom_configmethod that takes something typed aszarr_metadata.v3.codec.zstd.ZstdCodecConfigurationzarristato be known first party