Skip to content

Commit c40f623

Browse files
author
Test User
committed
issue zarr-developers#3795: Create public types for metadata objects
Expose metadata types as public API from the main zarr module: - ArrayV2Metadata and ArrayV3Metadata from zarr.core.metadata - GroupMetadata, ImplicitGroupMarker, and ConsolidatedMetadata from zarr.core.group - ChunkGrid and RegularChunkGrid from zarr.core.chunk_grids - ChunkKeyEncoding, DefaultChunkKeyEncoding, and V2ChunkKeyEncoding from zarr.core.chunk_key_encodings These types can now be imported directly from zarr for better type hints and API clarity. Also add __all__ exports to zarr.core.group to explicitly declare public types.
1 parent 420f11c commit c40f623

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

changes/3795.feature.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Create public types for metadata objects
2+
3+
Metadata objects are now available as public types from the main `zarr` module:
4+
5+
- `ArrayV2Metadata` and `ArrayV3Metadata` for array metadata
6+
- `GroupMetadata` and `ImplicitGroupMarker` for group metadata
7+
- `ChunkGrid` and `RegularChunkGrid` for chunk grid definitions
8+
- `ChunkKeyEncoding`, `DefaultChunkKeyEncoding`, and `V2ChunkKeyEncoding` for chunk key encoding strategies
9+
- `ConsolidatedMetadata` for consolidated metadata storage
10+
11+
These types can now be imported directly from `zarr` for better API clarity and type hints:
12+
13+
```python
14+
from zarr import ArrayV3Metadata, GroupMetadata, ChunkGrid
15+
```
16+
17+
Previously, these types were only accessible through private module paths like `zarr.core.metadata` or `zarr.core.group`.

src/zarr/__init__.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,21 @@
3535
zeros_like,
3636
)
3737
from zarr.core.array import Array, AsyncArray
38+
from zarr.core.chunk_grids import ChunkGrid, RegularChunkGrid
39+
from zarr.core.chunk_key_encodings import (
40+
ChunkKeyEncoding,
41+
DefaultChunkKeyEncoding,
42+
V2ChunkKeyEncoding,
43+
)
3844
from zarr.core.config import config
39-
from zarr.core.group import AsyncGroup, Group
45+
from zarr.core.group import (
46+
AsyncGroup,
47+
ConsolidatedMetadata,
48+
Group,
49+
GroupMetadata,
50+
ImplicitGroupMarker,
51+
)
52+
from zarr.core.metadata import ArrayV2Metadata, ArrayV3Metadata
4053

4154
# in case setuptools scm screw up and find version to be 0.0.0
4255
assert not __version__.startswith("0.0.0")
@@ -144,9 +157,19 @@ def set_format(log_format: str) -> None:
144157

145158
__all__ = [
146159
"Array",
160+
"ArrayV2Metadata",
161+
"ArrayV3Metadata",
147162
"AsyncArray",
148163
"AsyncGroup",
164+
"ChunkGrid",
165+
"ChunkKeyEncoding",
166+
"ConsolidatedMetadata",
167+
"DefaultChunkKeyEncoding",
149168
"Group",
169+
"GroupMetadata",
170+
"ImplicitGroupMarker",
171+
"RegularChunkGrid",
172+
"V2ChunkKeyEncoding",
150173
"__version__",
151174
"array",
152175
"config",

src/zarr/core/group.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@
8383

8484
logger = logging.getLogger("zarr.group")
8585

86+
__all__ = [
87+
"AsyncGroup",
88+
"ConsolidatedMetadata",
89+
"Group",
90+
"GroupMetadata",
91+
"ImplicitGroupMarker",
92+
]
93+
8694
DefaultT = TypeVar("DefaultT")
8795

8896

0 commit comments

Comments
 (0)