Skip to content

Commit 7a92479

Browse files
authored
Merge branch 'main' into fix-hypothesis
2 parents ec058cd + e5135f9 commit 7a92479

39 files changed

+1125
-194
lines changed

.github/workflows/releases.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
with:
5656
name: releases
5757
path: dist
58-
- uses: pypa/gh-action-pypi-publish@v1.11.0
58+
- uses: pypa/gh-action-pypi-publish@v1.12.2
5959
with:
6060
user: __token__
6161
password: ${{ secrets.pypi_password }}

.github/workflows/test.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,14 @@ jobs:
3333
numpy-version: '2.1'
3434
dependency-set: 'optional'
3535
os: 'macos-latest'
36-
# https://github.com/zarr-developers/zarr-python/issues/2438
37-
# - python-version: '3.11'
38-
# numpy-version: '1.25'
39-
# dependency-set: 'optional'
40-
# os: 'windows-latest'
41-
# - python-version: '3.13'
42-
# numpy-version: '2.1'
43-
# dependency-set: 'optional'
44-
# os: 'windows-latest'
36+
- python-version: '3.11'
37+
numpy-version: '1.25'
38+
dependency-set: 'optional'
39+
os: 'windows-latest'
40+
- python-version: '3.13'
41+
numpy-version: '2.1'
42+
dependency-set: 'optional'
43+
os: 'windows-latest'
4544
runs-on: ${{ matrix.os }}
4645

4746
steps:

pyproject.toml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,19 +269,25 @@ extend-exclude = [
269269
extend-select = [
270270
"ANN", # flake8-annotations
271271
"B", # flake8-bugbear
272+
"EXE", # flake8-executable
272273
"C4", # flake8-comprehensions
274+
"FA", # flake8-future-annotations
273275
"FLY", # flynt
274276
"FURB", # refurb
275277
"G", # flake8-logging-format
276278
"I", # isort
277279
"ISC", # flake8-implicit-str-concat
280+
"LOG", # flake8-logging
278281
"PERF", # Perflint
282+
"PIE", # flake8-pie
279283
"PGH", # pygrep-hooks
280284
"PT", # flake8-pytest-style
281285
"PYI", # flake8-pyi
282-
"RSE", # flake8-raise
283286
"RET", # flake8-return
287+
"RSE", # flake8-raise
284288
"RUF",
289+
"SIM", # flake8-simplify
290+
"SLOT", # flake8-slots
285291
"TCH", # flake8-type-checking
286292
"TRY", # tryceratops
287293
"UP", # pyupgrade
@@ -298,6 +304,7 @@ ignore = [
298304
"RET505",
299305
"RET506",
300306
"RUF005",
307+
"SIM108",
301308
"TRY003",
302309
"UP027", # deprecated
303310
"UP038", # https://github.com/astral-sh/ruff/issues/7871
@@ -319,7 +326,7 @@ ignore = [
319326
]
320327

321328
[tool.ruff.lint.extend-per-file-ignores]
322-
"tests/**" = ["ANN001", "ANN201"]
329+
"tests/**" = ["ANN001", "ANN201", "RUF029", "SIM117", "SIM300"]
323330

324331
[tool.mypy]
325332
python_version = "3.11"

src/zarr/abc/codec.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ def validate(self, *, shape: ChunkCoords, dtype: np.dtype[Any], chunk_grid: Chun
106106
chunk_grid : ChunkGrid
107107
The array chunk grid
108108
"""
109-
...
110109

111110
async def _decode_single(self, chunk_data: CodecOutput, chunk_spec: ArraySpec) -> CodecInput:
112111
raise NotImplementedError

src/zarr/abc/metadata.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,5 @@ def from_dict(cls, data: dict[str, JSON]) -> Self:
4242
"""
4343
Create an instance of the model from a dictionary
4444
"""
45-
...
4645

4746
return cls(**data)

src/zarr/abc/store.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from typing import TYPE_CHECKING, NamedTuple, Protocol, runtime_checkable
77

88
if TYPE_CHECKING:
9-
from collections.abc import AsyncGenerator, Iterable
9+
from collections.abc import AsyncGenerator, AsyncIterator, Iterable
1010
from types import TracebackType
1111
from typing import Any, Self, TypeAlias
1212

@@ -284,7 +284,6 @@ async def _set_many(self, values: Iterable[tuple[str, Buffer]]) -> None:
284284
Insert multiple (key, value) pairs into storage.
285285
"""
286286
await gather(*starmap(self.set, values))
287-
return
288287

289288
@property
290289
@abstractmethod
@@ -330,17 +329,19 @@ def supports_listing(self) -> bool:
330329
...
331330

332331
@abstractmethod
333-
def list(self) -> AsyncGenerator[str, None]:
332+
def list(self) -> AsyncIterator[str]:
334333
"""Retrieve all keys in the store.
335334
336335
Returns
337336
-------
338-
AsyncGenerator[str, None]
337+
AsyncIterator[str]
339338
"""
340-
...
339+
# This method should be async, like overridden methods in child classes.
340+
# However, that's not straightforward:
341+
# https://stackoverflow.com/questions/68905848
341342

342343
@abstractmethod
343-
def list_prefix(self, prefix: str) -> AsyncGenerator[str, None]:
344+
def list_prefix(self, prefix: str) -> AsyncIterator[str]:
344345
"""
345346
Retrieve all keys in the store that begin with a given prefix. Keys are returned relative
346347
to the root of the store.
@@ -351,12 +352,14 @@ def list_prefix(self, prefix: str) -> AsyncGenerator[str, None]:
351352
352353
Returns
353354
-------
354-
AsyncGenerator[str, None]
355+
AsyncIterator[str]
355356
"""
356-
...
357+
# This method should be async, like overridden methods in child classes.
358+
# However, that's not straightforward:
359+
# https://stackoverflow.com/questions/68905848
357360

358361
@abstractmethod
359-
def list_dir(self, prefix: str) -> AsyncGenerator[str, None]:
362+
def list_dir(self, prefix: str) -> AsyncIterator[str]:
360363
"""
361364
Retrieve all keys and prefixes with a given prefix and which do not contain the character
362365
“/” after the given prefix.
@@ -367,9 +370,11 @@ def list_dir(self, prefix: str) -> AsyncGenerator[str, None]:
367370
368371
Returns
369372
-------
370-
AsyncGenerator[str, None]
373+
AsyncIterator[str]
371374
"""
372-
...
375+
# This method should be async, like overridden methods in child classes.
376+
# However, that's not straightforward:
377+
# https://stackoverflow.com/questions/68905848
373378

374379
async def delete_dir(self, prefix: str) -> None:
375380
"""

src/zarr/api/asynchronous.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from zarr.abc.store import Store
1212
from zarr.core.array import Array, AsyncArray, get_array_metadata
13+
from zarr.core.buffer import NDArrayLike
1314
from zarr.core.common import (
1415
JSON,
1516
AccessModeLiteral,
@@ -31,7 +32,6 @@
3132
from collections.abc import Iterable
3233

3334
from zarr.abc.codec import Codec
34-
from zarr.core.buffer import NDArrayLike
3535
from zarr.core.chunk_key_encodings import ChunkKeyEncoding
3636

3737
# TODO: this type could use some more thought
@@ -393,6 +393,8 @@ async def save_array(
393393
_handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
394394
or _default_zarr_version()
395395
)
396+
if not isinstance(arr, NDArrayLike):
397+
raise TypeError("arr argument must be numpy or other NDArrayLike array")
396398

397399
mode = kwargs.pop("mode", None)
398400
store_path = await make_store_path(store, path=path, mode=mode, storage_options=storage_options)
@@ -447,16 +449,26 @@ async def save_group(
447449
or _default_zarr_version()
448450
)
449451

452+
for arg in args:
453+
if not isinstance(arg, NDArrayLike):
454+
raise TypeError(
455+
"All arguments must be numpy or other NDArrayLike arrays (except store, path, storage_options, and zarr_format)"
456+
)
457+
for k, v in kwargs.items():
458+
if not isinstance(v, NDArrayLike):
459+
raise TypeError(f"Keyword argument '{k}' must be a numpy or other NDArrayLike array")
460+
450461
if len(args) == 0 and len(kwargs) == 0:
451462
raise ValueError("at least one array must be provided")
452463
aws = []
453464
for i, arr in enumerate(args):
465+
_path = f"{path}/arr_{i}" if path is not None else f"arr_{i}"
454466
aws.append(
455467
save_array(
456468
store,
457469
arr,
458470
zarr_format=zarr_format,
459-
path=f"{path}/arr_{i}",
471+
path=_path,
460472
storage_options=storage_options,
461473
)
462474
)
@@ -866,9 +878,8 @@ async def create(
866878
warnings.warn("meta_array is not yet implemented", RuntimeWarning, stacklevel=2)
867879

868880
mode = kwargs.pop("mode", None)
869-
if mode is None:
870-
if not isinstance(store, Store | StorePath):
871-
mode = "a"
881+
if mode is None and not isinstance(store, Store | StorePath):
882+
mode = "a"
872883

873884
store_path = await make_store_path(store, path=path, mode=mode, storage_options=storage_options)
874885

src/zarr/codecs/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@
99
from zarr.codecs.bytes import BytesCodec, Endian
1010
from zarr.codecs.crc32c_ import Crc32cCodec
1111
from zarr.codecs.gzip import GzipCodec
12-
from zarr.codecs.pipeline import BatchedCodecPipeline
1312
from zarr.codecs.sharding import ShardingCodec, ShardingCodecIndexLocation
1413
from zarr.codecs.transpose import TransposeCodec
1514
from zarr.codecs.vlen_utf8 import VLenBytesCodec, VLenUTF8Codec
1615
from zarr.codecs.zstd import ZstdCodec
1716
from zarr.core.metadata.v3 import DataType
1817

1918
__all__ = [
20-
"BatchedCodecPipeline",
2119
"BloscCname",
2220
"BloscCodec",
2321
"BloscShuffle",

src/zarr/codecs/gzip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
def parse_gzip_level(data: JSON) -> int:
2222
if not isinstance(data, (int)):
2323
raise TypeError(f"Expected int, got {type(data)}")
24-
if data not in range(0, 10):
24+
if data not in range(10):
2525
raise ValueError(
2626
f"Expected an integer from the inclusive range (0, 9). Got {data} instead."
2727
)

src/zarr/codecs/registry.py

Whitespace-only changes.

0 commit comments

Comments
 (0)