Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changes/3990.misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Widen `ChunksLike` type alias to use `Iterable` instead of `Sequence`, and also
remove `None` from the type union. This supports a broader range of types,
removing the necessity to "materialize" iterable values simply to satisfy type
annotations. It also allows use of `ChunksLike` in cases where `None` should
not be permitted.
17 changes: 6 additions & 11 deletions src/zarr/core/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -4397,11 +4397,8 @@ async def init_array(
chunk_key_encoding, zarr_format=zarr_format
)

if overwrite:
if store_path.store.supports_deletes:
await store_path.delete_dir()
else:
await ensure_no_existing_node(store_path, zarr_format=zarr_format)
if overwrite and store_path.store.supports_deletes:
await store_path.delete_dir()
else:
await ensure_no_existing_node(store_path, zarr_format=zarr_format)

Expand All @@ -4417,12 +4414,10 @@ async def init_array(
)

# Normalize the user's chunks into canonical ChunksTuple form
if chunks is None or chunks == "auto":
chunks_normalized = guess_chunks(
shape_parsed,
item_size,
max_bytes=SHARDED_INNER_CHUNK_MAX_BYTES if shards is not None else None,
)

if chunks == "auto":
max_bytes = None if shards is None else SHARDED_INNER_CHUNK_MAX_BYTES
chunks_normalized = guess_chunks(shape_parsed, item_size, max_bytes=max_bytes)
else:
chunks_normalized = normalize_chunks_nd(chunks, shape_parsed)

Expand Down
2 changes: 1 addition & 1 deletion src/zarr/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

BytesLike = bytes | bytearray | memoryview
ShapeLike = Iterable[int | np.integer[Any]] | int | np.integer[Any]
ChunksLike = ShapeLike | Sequence[Sequence[int]] | None
ChunksLike = ShapeLike | Iterable[Iterable[int]]
# For backwards compatibility
ChunkCoords = tuple[int, ...]
ZarrFormat = Literal[2, 3]
Expand Down
Loading