Skip to content

Commit 807c585

Browse files
committed
changes necessary for linting with regression tests
1 parent 4a7a550 commit 807c585

File tree

6 files changed

+20
-6
lines changed

6 files changed

+20
-6
lines changed

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ extend-exclude = [
283283
"notebooks", # temporary, until we achieve compatibility with ruff ≥ 0.6
284284
"venv",
285285
"docs",
286+
"tests/test_regression/scripts/", # these are scripts that use a different version of python
286287
"src/zarr/v2/",
287288
"tests/v2/",
288289
]
@@ -353,7 +354,6 @@ strict = true
353354
warn_unreachable = true
354355
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
355356

356-
357357
[[tool.mypy.overrides]]
358358
module = [
359359
"tests.package_with_entrypoint.*",
@@ -383,6 +383,7 @@ module = [
383383
"tests.test_properties",
384384
"tests.test_sync",
385385
"tests.test_v2",
386+
"tests.test_regression.scripts.*"
386387
]
387388
ignore_errors = true
388389

src/zarr/core/dtype/wrapper.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
# This is the bound for the dtypes that we support. If we support non-numpy dtypes,
4040
# then this bound will need to be widened.
4141
TBaseDType = np.dtype[np.generic]
42+
4243
# These two type parameters are covariant because we want
4344
# x : ZDType[BaseDType, BaseScalar] = ZDType[SubDType, SubScalar]
4445
# to type check

tests/test_dtype/test_wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def scalar_equals(self, scalar1: object, scalar2: object) -> bool:
9191
# but some classes may need to override this for special cases
9292
return scalar1 == scalar2
9393

94-
def test_check_dtype_valid(self, valid_dtype: object) -> None:
94+
def test_check_dtype_valid(self, valid_dtype: TBaseDType) -> None:
9595
assert self.test_cls.check_dtype(valid_dtype)
9696

9797
def test_check_dtype_invalid(self, invalid_dtype: object) -> None:

tests/test_regression/scripts/__init__.py

Whitespace-only changes.

tests/test_regression/test_regression.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from dataclasses import dataclass
33
from itertools import product
44
from pathlib import Path
5+
from typing import TYPE_CHECKING
56

67
import numcodecs
78
import numpy as np
@@ -10,9 +11,13 @@
1011

1112
import zarr
1213
from zarr.core.array import Array
14+
from zarr.core.chunk_key_encodings import V2ChunkKeyEncoding
1315
from zarr.core.dtype.npy.string import VariableLengthString
1416
from zarr.storage import LocalStore
1517

18+
if TYPE_CHECKING:
19+
from zarr.core.dtype import ZDTypeLike
20+
1621

1722
def runner_installed() -> bool:
1823
"""
@@ -69,8 +74,10 @@ def source_array(tmp_path: Path, request: pytest.FixtureRequest) -> Array:
6974
store = LocalStore(dest)
7075
array_params: ArrayParams = request.param
7176
compressor = array_params.compressor
77+
chunk_key_encoding = V2ChunkKeyEncoding(separator="/")
78+
dtype: ZDTypeLike
7279
if array_params.values.dtype == np.dtype("|O"):
73-
dtype = VariableLengthString()
80+
dtype = VariableLengthString() # type: ignore[assignment]
7481
else:
7582
dtype = array_params.values.dtype
7683
z = zarr.create_array(
@@ -82,25 +89,30 @@ def source_array(tmp_path: Path, request: pytest.FixtureRequest) -> Array:
8289
fill_value=array_params.fill_value,
8390
order="C",
8491
filters=None,
85-
chunk_key_encoding={"name": "v2", "configuration": {"separator": "/"}},
92+
chunk_key_encoding=chunk_key_encoding,
8693
write_data=True,
8794
zarr_format=2,
8895
)
8996
z[:] = array_params.values
9097
return z
9198

9299

100+
# TODO: make this dynamic based on the installed scripts
101+
script_paths = [Path(__file__).resolve().parent / "scripts" / "v2.18.py"]
102+
103+
93104
@pytest.mark.skipif(not runner_installed(), reason="no python script runner installed")
94105
@pytest.mark.parametrize(
95106
"source_array", array_cases, indirect=True, ids=tuple(map(str, array_cases))
96107
)
97-
def test_roundtrip(source_array: Array, tmp_path: Path) -> None:
108+
@pytest.mark.parametrize("script_path", script_paths)
109+
def test_roundtrip(source_array: Array, tmp_path: Path, script_path: Path) -> None:
98110
out_path = tmp_path / "out"
99111
copy_op = subprocess.run(
100112
[
101113
"uv",
102114
"run",
103-
Path(__file__).resolve().parent / "v2.18.py",
115+
script_path,
104116
str(source_array.store).removeprefix("file://"),
105117
str(out_path),
106118
],

0 commit comments

Comments
 (0)