Skip to content

Commit cbb32d7

Browse files
committed
lint
1 parent 9980823 commit cbb32d7

File tree

7 files changed

+60
-25
lines changed

7 files changed

+60
-25
lines changed

tests/test_codecs/test_blosc.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@
88
import zarr
99
from zarr.abc.store import Store
1010
from zarr.codecs import BloscCodec
11-
from zarr.codecs.blosc import BLOSC_CNAME, BLOSC_SHUFFLE, BloscCname, BloscJSON_V2, BloscJSON_V3, BloscShuffle
11+
from zarr.codecs.blosc import (
12+
BLOSC_CNAME,
13+
BLOSC_SHUFFLE,
14+
BloscCname,
15+
BloscJSON_V2,
16+
BloscJSON_V3,
17+
BloscShuffle,
18+
)
1219
from zarr.core.buffer import default_buffer_prototype
1320
from zarr.storage import StorePath
1421

tests/test_codecs/test_bytes.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
from typing import Literal
1+
from typing import TYPE_CHECKING, Literal
22

33
import numpy as np
44
import pytest
55

66
import zarr
77
from zarr.abc.store import Store
88
from zarr.codecs import BytesCodec
9-
from zarr.codecs.bytes import BytesJSON_V2, BytesJSON_V3
109
from zarr.storage import StorePath
1110

1211
from .test_codecs import _AsyncArrayProxy
1312

13+
if TYPE_CHECKING:
14+
from zarr.codecs.bytes import BytesJSON_V2, BytesJSON_V3
15+
16+
1417
@pytest.mark.parametrize("endian", ["big", "little"])
1518
def test_bytescodec_to_json(endian: Literal["big", "little"]) -> None:
1619
codec = BytesCodec(endian=endian)

tests/test_codecs/test_gzip.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1+
from typing import TYPE_CHECKING
2+
13
import numpy as np
24
import pytest
35

46
import zarr
57
from zarr.abc.store import Store
68
from zarr.codecs import GzipCodec
7-
from zarr.codecs.gzip import GZipJSON_V2, GZipJSON_V3
89
from zarr.storage import StorePath
910

11+
if TYPE_CHECKING:
12+
from zarr.codecs.gzip import GZipJSON_V2, GZipJSON_V3
13+
14+
1015
@pytest.mark.parametrize("level", [1, 5, 9])
1116
def test_json(level: int) -> None:
1217
codec = GzipCodec(level=level)

tests/test_codecs/test_sharding.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from codecs import Codec
21
import pickle
3-
from typing import Any, Literal
2+
from codecs import Codec
3+
from typing import TYPE_CHECKING, Any, Literal
44

55
import numpy as np
66
import numpy.typing as npt
@@ -19,20 +19,32 @@
1919
)
2020
from zarr.codecs.bytes import BytesCodec
2121
from zarr.codecs.crc32c_ import Crc32cCodec
22-
from zarr.codecs.sharding import ShardingJSON_V2, ShardingJSON_V3
2322
from zarr.core.buffer import NDArrayLike, default_buffer_prototype
2423
from zarr.storage import StorePath
2524

2625
from ..conftest import ArrayRequest
2726
from .test_codecs import _AsyncArrayProxy, order_from_dim
2827

28+
if TYPE_CHECKING:
29+
from zarr.codecs.sharding import ShardingJSON_V2, ShardingJSON_V3
30+
2931

3032
@pytest.mark.parametrize("index_location", ["start", "end"])
3133
@pytest.mark.parametrize("chunk_shape", [(32, 32), (64, 64)])
32-
@pytest.mark.parametrize('codecs', [(BytesCodec(),)])
33-
@pytest.mark.parametrize('index_codecs', [(Crc32cCodec(),)])
34-
def test_sharding_codec_to_json(index_location: Literal["start", "end"], chunk_shape: tuple[int, ...], codecs: tuple[Codec, ...], index_codecs: tuple[Codec, ...]) -> None:
35-
codec = ShardingCodec(chunk_shape=chunk_shape, codecs=codecs, index_location=index_location, index_codecs=index_codecs)
34+
@pytest.mark.parametrize("codecs", [(BytesCodec(),)])
35+
@pytest.mark.parametrize("index_codecs", [(Crc32cCodec(),)])
36+
def test_sharding_codec_to_json(
37+
index_location: Literal["start", "end"],
38+
chunk_shape: tuple[int, ...],
39+
codecs: tuple[Codec, ...],
40+
index_codecs: tuple[Codec, ...],
41+
) -> None:
42+
codec = ShardingCodec(
43+
chunk_shape=chunk_shape,
44+
codecs=codecs,
45+
index_location=index_location,
46+
index_codecs=index_codecs,
47+
)
3648
expected_v2: ShardingJSON_V2 = {
3749
"id": "sharding_indexed",
3850
"chunk_shape": chunk_shape,
@@ -43,10 +55,10 @@ def test_sharding_codec_to_json(index_location: Literal["start", "end"], chunk_s
4355
expected_v3: ShardingJSON_V3 = {
4456
"name": "sharding_indexed",
4557
"configuration": {
46-
"chunk_shape": chunk_shape,
47-
"codecs": tuple(c.to_json(zarr_format=3) for c in codecs),
48-
"index_codecs": tuple(c.to_json(zarr_format=3) for c in index_codecs),
49-
"index_location": index_location,
58+
"chunk_shape": chunk_shape,
59+
"codecs": tuple(c.to_json(zarr_format=3) for c in codecs),
60+
"index_codecs": tuple(c.to_json(zarr_format=3) for c in index_codecs),
61+
"index_location": index_location,
5062
},
5163
}
5264
assert codec.to_json(zarr_format=2) == expected_v2

tests/test_codecs/test_transpose.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1+
from typing import TYPE_CHECKING
2+
13
import numpy as np
24
import pytest
35

46
import zarr
57
from zarr import AsyncArray, config
68
from zarr.abc.store import Store
79
from zarr.codecs import TransposeCodec
8-
from zarr.codecs.transpose import TransposeJSON_V2, TransposeJSON_V3
910
from zarr.core.common import MemoryOrder
1011
from zarr.storage import StorePath
1112

1213
from .test_codecs import _AsyncArrayProxy
1314

15+
if TYPE_CHECKING:
16+
from zarr.codecs.transpose import TransposeJSON_V2, TransposeJSON_V3
17+
1418

15-
@pytest.mark.parametrize("order", [(1,2,3), (2,1,0)])
19+
@pytest.mark.parametrize("order", [(1, 2, 3), (2, 1, 0)])
1620
def test_transpose_to_json(order: tuple[int, ...]) -> None:
1721
codec = TransposeCodec(order=order)
1822
expected_v2: TransposeJSON_V2 = {"id": "transpose", "order": order}
@@ -23,6 +27,7 @@ def test_transpose_to_json(order: tuple[int, ...]) -> None:
2327
assert codec.to_json(zarr_format=2) == expected_v2
2428
assert codec.to_json(zarr_format=3) == expected_v3
2529

30+
2631
@pytest.mark.parametrize("input_order", ["F", "C"])
2732
@pytest.mark.parametrize("runtime_write_order", ["F", "C"])
2833
@pytest.mark.parametrize("runtime_read_order", ["F", "C"])

tests/test_codecs/test_vlen.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
else:
2323
expected_array_string_dtype = np.dtype("O")
2424

25+
2526
def test_vlen_utf8_to_json() -> None:
2627
codec = VLenUTF8Codec()
27-
expected_v2: VLenUTF8JSON_V2 = {
28-
"id": "vlen-utf8"}
28+
expected_v2: VLenUTF8JSON_V2 = {"id": "vlen-utf8"}
2929
expected_v3: VLenUTF8JSON_V3 = {
3030
"name": "vlen-utf8",
3131
}

tests/test_codecs/test_zstd.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1+
from typing import TYPE_CHECKING
2+
13
import numpy as np
24
import pytest
35

46
import zarr
57
from zarr.abc.store import Store
68
from zarr.codecs import ZstdCodec
7-
from zarr.codecs.zstd import ZstdJSON_V2, ZstdJSON_V3
89
from zarr.storage import StorePath
910

11+
if TYPE_CHECKING:
12+
from zarr.codecs.zstd import ZstdJSON_V2, ZstdJSON_V3
13+
14+
1015
@pytest.mark.parametrize("level", [1, 5, 9])
11-
@pytest.mark.parametrize('checksum', [True, False])
16+
@pytest.mark.parametrize("checksum", [True, False])
1217
def test_json(level: int, checksum: bool) -> None:
1318
codec = ZstdCodec(level=level, checksum=checksum)
1419
expected_v2: ZstdJSON_V2 = {
@@ -17,14 +22,12 @@ def test_json(level: int, checksum: bool) -> None:
1722
}
1823
expected_v3: ZstdJSON_V3 = {
1924
"name": "zstd",
20-
"configuration": {
21-
"level": level,
22-
"checksum": checksum
23-
},
25+
"configuration": {"level": level, "checksum": checksum},
2426
}
2527
assert codec.to_json(zarr_format=2) == expected_v2
2628
assert codec.to_json(zarr_format=3) == expected_v3
2729

30+
2831
@pytest.mark.parametrize("store", ["local", "memory"], indirect=["store"])
2932
@pytest.mark.parametrize("checksum", [True, False])
3033
def test_zstd(store: Store, checksum: bool) -> None:

0 commit comments

Comments
 (0)