Skip to content

feat: Add DataType.from_name constructor#37

Merged
kylebarron merged 7 commits into
mainfrom
kyle/extract-dtype
Jun 22, 2026
Merged

feat: Add DataType.from_name constructor#37
kylebarron merged 7 commits into
mainfrom
kyle/extract-dtype

Conversation

@kylebarron

@kylebarron kylebarron commented Jun 22, 2026

Copy link
Copy Markdown
Member

At first this PR was planned to be

Support string input wherever `DataType` is expected

which would have supported

example_function(dtype: string | dict | DataType)

but that's kinda messy. Perhaps that's a good API for a higher level Zarr-Python API, but I think at the Zarrista level we should always aim to be explicit.

Instead, this PR just adds DataType.from_name and changes the existing constructor to DataType.from_metadata

@kylebarron kylebarron changed the title wip: Support string input wherever DataType is expected feat: Add DataType.from_name constructor Jun 22, 2026
@kylebarron kylebarron marked this pull request as ready for review June 22, 2026 19:28
Comment on lines +32 to +55
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.

Documents the common names for editor autocompletion; arbitrary strings (e.g.
raw `"r*"` types or extension data types) are still accepted by
`DataType.from_string`.
"""

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This will change to using zarr-metadata in the next PR

@kylebarron kylebarron enabled auto-merge (squash) June 22, 2026 19:29
@kylebarron kylebarron merged commit c794a93 into main Jun 22, 2026
6 checks passed
@kylebarron kylebarron deleted the kyle/extract-dtype branch June 22, 2026 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant