Skip to content

Commit 262e369

Browse files
committed
lint
1 parent dfca3ec commit 262e369

File tree

9 files changed

+52
-18
lines changed

9 files changed

+52
-18
lines changed

src/zarr/codecs/blosc.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@
1414
overload,
1515
)
1616

17-
from typing_extensions import ReadOnly
18-
1917
import numcodecs
2018
from numcodecs.blosc import Blosc
2119
from packaging.version import Version
20+
from typing_extensions import ReadOnly
2221

23-
from zarr.abc.codec import BytesBytesCodec, CodecJSON, CodecJSON_V2
22+
from zarr.abc.codec import BytesBytesCodec, CodecJSON
2423
from zarr.core.buffer.cpu import as_numpy_array_wrapper
2524
from zarr.core.common import (
2625
JSON,
@@ -64,8 +63,10 @@ class BloscJSON_V2(BloscConfigV2):
6463
"""
6564
The JSON form of the Blosc codec in Zarr V2.
6665
"""
66+
6767
id: ReadOnly[Literal["blosc"]]
6868

69+
6970
class BloscJSON_V3(NamedRequiredConfig[Literal["blosc"], BloscConfigV3]):
7071
"""
7172
The JSON form of the Blosc codec in Zarr V3.

src/zarr/codecs/bytes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class BytesJSON_V2(BytesConfig):
4545
"""
4646
JSON representation of the bytes codec for zarr v2.
4747
"""
48+
4849
id: ReadOnly[Literal["bytes"]]
4950

5051

src/zarr/codecs/crc32c_.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010

1111
from zarr.abc.codec import BytesBytesCodec, CodecJSON, CodecJSON_V2
1212
from zarr.core.common import JSON, NamedConfig, ZarrFormat, parse_named_configuration
13-
from zarr.registry import register_codec
1413
from zarr.errors import CodecValidationError
14+
from zarr.registry import register_codec
15+
1516
if TYPE_CHECKING:
1617
from typing import Self
1718

src/zarr/codecs/gzip.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
from numcodecs.gzip import GZip
99
from typing_extensions import ReadOnly
10-
from zarr.abc.codec import BytesBytesCodec, CodecJSON, CodecJSON_V2
10+
11+
from zarr.abc.codec import BytesBytesCodec, CodecJSON
1112
from zarr.core.buffer.cpu import as_numpy_array_wrapper
1213
from zarr.core.common import (
1314
JSON,
@@ -41,6 +42,7 @@ class GZipJSON_V2(GZipConfig):
4142
"""
4243
The JSON form of the GZip codec in Zarr V2.
4344
"""
45+
4446
id: ReadOnly[Literal["gzip"]]
4547

4648

src/zarr/codecs/sharding.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
cast,
1818
overload,
1919
)
20-
from typing_extensions import ReadOnly
20+
2121
import numpy as np
2222
import numpy.typing as npt
23+
from typing_extensions import ReadOnly
2324

2425
from zarr.abc.codec import (
2526
ArrayBytesCodec,
@@ -31,7 +32,6 @@
3132
CodecJSON_V3,
3233
CodecPipeline,
3334
)
34-
from zarr.errors import CodecValidationError
3535
from zarr.abc.store import (
3636
ByteGetter,
3737
ByteRequest,
@@ -67,6 +67,7 @@
6767
morton_order_iter,
6868
)
6969
from zarr.core.metadata.v3 import parse_codecs
70+
from zarr.errors import CodecValidationError
7071
from zarr.registry import get_ndbuffer_class, get_pipeline_class, register_codec
7172

7273
if TYPE_CHECKING:
@@ -101,8 +102,10 @@ class ShardingJSON_V2(ShardingConfigV2):
101102
"""
102103
The JSON form of the sharding codec in Zarr V2.
103104
"""
105+
104106
id: ReadOnly[Literal["sharding_indexed"]]
105107

108+
106109
class ShardingJSON_V3(NamedRequiredConfig[Literal["sharding_indexed"], ShardingConfigV3]): ...
107110

108111

src/zarr/codecs/transpose.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
import numpy as np
88
from typing_extensions import ReadOnly
9-
from zarr.abc.codec import ArrayArrayCodec, CodecJSON, CodecJSON_V2
9+
10+
from zarr.abc.codec import ArrayArrayCodec, CodecJSON
1011
from zarr.core.array_spec import ArraySpec
1112
from zarr.core.common import (
1213
JSON,
@@ -41,8 +42,10 @@ class TransposeJSON_V2(TransposeConfig):
4142
"""
4243
The JSON form of the Transpose codec in Zarr V2.
4344
"""
45+
4446
id: ReadOnly[Literal["transpose"]]
4547

48+
4649
class TransposeJSON_V3(NamedRequiredConfig[Literal["transpose"], TransposeConfig]):
4750
"""
4851
The JSON form of the Transpose codec in Zarr V3.

src/zarr/codecs/zstd.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@
99
import numcodecs
1010
from numcodecs.zstd import Zstd
1111
from packaging.version import Version
12-
from zarr.errors import CodecValidationError
1312
from typing_extensions import ReadOnly
13+
1414
from zarr.abc.codec import BytesBytesCodec, CodecJSON
1515
from zarr.core.buffer.cpu import as_numpy_array_wrapper
1616
from zarr.core.common import (
1717
JSON,
1818
NamedRequiredConfig,
1919
ZarrFormat,
2020
)
21+
from zarr.errors import CodecValidationError
2122
from zarr.registry import register_codec
2223

2324
if TYPE_CHECKING:
@@ -40,6 +41,7 @@ class ZstdJSON_V2(ZstdConfig_V2):
4041
"""
4142
The JSON form of the ZStandard codec in Zarr v2.
4243
"""
44+
4345
id: ReadOnly[Literal["zstd"]]
4446

4547

src/zarr/errors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class NodeTypeValidationError(MetadataValidationError):
6767
for example an 'array' node when we expected a 'group'.
6868
"""
6969

70+
7071
class CodecValidationError(BaseZarrError):
7172
"""Raised when the Zarr codec metadata is invalid in some way"""
7273

tests/test_codecs/test_blosc.py

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,38 @@
1313
from zarr.storage import StorePath
1414

1515

16-
@pytest.mark.parametrize('shuffle', BLOSC_SHUFFLE)
17-
@pytest.mark.parametrize('cname', BLOSC_CNAME)
18-
@pytest.mark.parametrize('clevel', [1,2])
19-
@pytest.mark.parametrize('blocksize', [1,2])
20-
@pytest.mark.parametrize('typesize', [1,2])
21-
def test_to_json_v2(cname: BloscCname, shuffle: BloscShuffle, clevel: int, blocksize: int, typesize: int) -> None:
22-
codec= BloscCodec(shuffle=shuffle, cname=cname, clevel=clevel, blocksize=blocksize, typesize=typesize)
23-
expected_v2: BloscJSON_V2 = {"id": "blosc", "cname": cname, "clevel": clevel, "shuffle": BLOSC_SHUFFLE.index(shuffle), "blocksize": blocksize}
24-
expected_v3: BloscJSON_V3 = {"name": "blosc", "configuration": {"cname": cname, "clevel": clevel, "shuffle": shuffle, "blocksize": blocksize, "typesize": typesize}}
16+
@pytest.mark.parametrize("shuffle", BLOSC_SHUFFLE)
17+
@pytest.mark.parametrize("cname", BLOSC_CNAME)
18+
@pytest.mark.parametrize("clevel", [1, 2])
19+
@pytest.mark.parametrize("blocksize", [1, 2])
20+
@pytest.mark.parametrize("typesize", [1, 2])
21+
def test_to_json_v2(
22+
cname: BloscCname, shuffle: BloscShuffle, clevel: int, blocksize: int, typesize: int
23+
) -> None:
24+
codec = BloscCodec(
25+
shuffle=shuffle, cname=cname, clevel=clevel, blocksize=blocksize, typesize=typesize
26+
)
27+
expected_v2: BloscJSON_V2 = {
28+
"id": "blosc",
29+
"cname": cname,
30+
"clevel": clevel,
31+
"shuffle": BLOSC_SHUFFLE.index(shuffle),
32+
"blocksize": blocksize,
33+
}
34+
expected_v3: BloscJSON_V3 = {
35+
"name": "blosc",
36+
"configuration": {
37+
"cname": cname,
38+
"clevel": clevel,
39+
"shuffle": shuffle,
40+
"blocksize": blocksize,
41+
"typesize": typesize,
42+
},
43+
}
2544
assert codec.to_json(zarr_format=2) == expected_v2
2645
assert codec.to_json(zarr_format=3) == expected_v3
2746

47+
2848
@pytest.mark.parametrize("store", ["local", "memory"], indirect=["store"])
2949
@pytest.mark.parametrize("dtype", ["uint8", "uint16"])
3050
async def test_blosc_evolve(store: Store, dtype: str) -> None:

0 commit comments

Comments
 (0)