Skip to content

Commit f4598c8

Browse files
committed
lint
1 parent d0d5e92 commit f4598c8

22 files changed

+142
-112
lines changed

src/zarr/codecs/numcodecs/adler32.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,20 @@
99
_NumcodecsChecksumCodec,
1010
_warn_unstable_specification,
1111
)
12-
from zarr.core.common import CodecJSON, CodecJSON_V2, CodecJSON_V3, NamedConfig, ZarrFormat, _check_codecjson_v2, _check_codecjson_v3
12+
from zarr.core.common import (
13+
CodecJSON,
14+
CodecJSON_V2,
15+
CodecJSON_V3,
16+
NamedConfig,
17+
ZarrFormat,
18+
_check_codecjson_v2,
19+
_check_codecjson_v3,
20+
)
1321

1422
if TYPE_CHECKING:
1523
...
1624

25+
1726
class Adler32Config(TypedDict):
1827
"""Configuration parameters for Adler32 codec."""
1928

@@ -25,9 +34,11 @@ class Adler32JSON_V2(Adler32Config):
2534

2635
id: ReadOnly[Literal["adler32"]]
2736

37+
2838
class Adler32JSON_V3_Legacy(NamedConfig[Literal["numcodecs.adler32"], Adler32Config]):
2939
"""Legacy JSON representation of Adler32 codec for Zarr V3."""
3040

41+
3142
class Adler32JSON_V3(NamedConfig[Literal["adler32"], Adler32Config]):
3243
"""JSON representation of Adler32 codec for Zarr V3."""
3344

@@ -80,7 +91,6 @@ def to_json(self, zarr_format: ZarrFormat) -> Adler32JSON_V2 | Adler32JSON_V3:
8091
_warn_unstable_specification(self)
8192
return super().to_json(zarr_format) # type: ignore[return-value]
8293

83-
8494
@classmethod
8595
def _from_json_v2(cls, data: CodecJSON_V2) -> Self:
8696
return cls(**data)
@@ -96,4 +106,4 @@ def _from_json_v3(cls, data: CodecJSON_V3) -> Self:
96106
def from_json(cls, data: CodecJSON) -> Self:
97107
if _check_codecjson_v2(data):
98108
return cls._from_json_v2(data)
99-
return cls._from_json_v3(data)
109+
return cls._from_json_v3(data)

src/zarr/codecs/numcodecs/bitround.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from collections.abc import Mapping
4-
from typing import TYPE_CHECKING, Literal, Self, TypedDict, TypeGuard, overload
4+
from typing import Literal, Self, TypedDict, TypeGuard, overload
55

66
from typing_extensions import ReadOnly
77

@@ -19,9 +19,6 @@
1919
_check_codecjson_v3,
2020
)
2121

22-
if TYPE_CHECKING:
23-
pass
24-
2522

2623
class BitRoundConfig(TypedDict):
2724
keepbits: int
@@ -36,6 +33,7 @@ class BitRoundJSON_V2(BitRoundConfig):
3633
class BitRoundJSON_V3_Legacy(NamedRequiredConfig[Literal["numcodecs.bitround"], BitRoundConfig]):
3734
"""JSON representation of BitRound codec for Zarr V3."""
3835

36+
3937
class BitRoundJSON_V3(NamedRequiredConfig[Literal["bitround"], BitRoundConfig]):
4038
"""JSON representation of BitRound codec for Zarr V3."""
4139

@@ -102,4 +100,4 @@ def _from_json_v3(cls, data: CodecJSON_V3) -> Self:
102100
def from_json(cls, data: CodecJSON) -> Self:
103101
if _check_codecjson_v2(data):
104102
return cls._from_json_v2(data)
105-
return cls._from_json_v3(data)
103+
return cls._from_json_v3(data)

src/zarr/codecs/numcodecs/blosc.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,31 @@
1616
if TYPE_CHECKING:
1717
from zarr.codecs.blosc import BloscCname_Lit, BloscJSON_V2
1818

19-
# This is different from zarr.codecs.blosc
19+
20+
# This is different from zarr.codecs.blosc
2021
class BloscConfigV3_Legacy(TypedDict):
2122
cname: BloscCname_Lit
2223
clevel: int
2324
shuffle: int
2425
blocksize: int
2526

27+
2628
class BloscJSON_V3_Legacy(NamedRequiredConfig[Literal["numcodecs.blosc"], BloscConfigV3_Legacy]):
2729
"""
2830
Legacy JSON form of the Blosc codec in Zarr V3.
2931
"""
3032

33+
3134
def check_json_v3(data: object) -> TypeGuard[BloscJSON_V3_Legacy]:
3235
return (
3336
isinstance(data, Mapping)
3437
and set(data.keys()) == {"name", "configuration"}
3538
and data["name"] in ("blosc", "numcodecs.blosc")
3639
and isinstance(data["configuration"], Mapping)
37-
and set(data["configuration"].keys())
38-
== {"cname", "clevel", "shuffle", "blocksize"}
40+
and set(data["configuration"].keys()) == {"cname", "clevel", "shuffle", "blocksize"}
3941
)
4042

43+
4144
class Blosc(_NumcodecsBytesBytesCodec):
4245
"""
4346
A legacy wrapper used to provide a Zarr V3 API for the numcodecs blosc codec.
@@ -70,4 +73,4 @@ def _from_json_v3(cls, data: CodecJSON_V3) -> Self:
7073
def from_json(cls, data: CodecJSON) -> Self:
7174
if _check_codecjson_v2(data):
7275
return cls._from_json_v2(data)
73-
return cls._from_json_v3(data)
76+
return cls._from_json_v3(data)

src/zarr/codecs/numcodecs/bz2.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from collections.abc import Mapping
4-
from typing import TYPE_CHECKING, Literal, Self, TypedDict, TypeGuard, overload
4+
from typing import Literal, Self, TypedDict, TypeGuard, overload
55

66
from typing_extensions import ReadOnly
77

@@ -19,9 +19,6 @@
1919
_check_codecjson_v3,
2020
)
2121

22-
if TYPE_CHECKING:
23-
pass
24-
2522

2623
class BZ2Config(TypedDict):
2724
level: int
@@ -32,9 +29,11 @@ class BZ2JSON_V2(BZ2Config):
3229

3330
id: ReadOnly[Literal["bz2"]]
3431

32+
3533
class BZ2JSON_V3_Legacy(NamedRequiredConfig[Literal["numcodecs.bz2"], BZ2Config]):
3634
"""Legacy JSON representation of BZ2 codec for Zarr V3."""
3735

36+
3837
class BZ2JSON_V3(NamedRequiredConfig[Literal["bz2"], BZ2Config]):
3938
"""JSON representation of BZ2 codec for Zarr V3."""
4039

@@ -101,4 +100,4 @@ def _from_json_v3(cls, data: CodecJSON_V3) -> Self:
101100
def from_json(cls, data: CodecJSON) -> Self:
102101
if _check_codecjson_v2(data):
103102
return cls._from_json_v2(data)
104-
return cls._from_json_v3(data)
103+
return cls._from_json_v3(data)

src/zarr/codecs/numcodecs/crc32.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
from __future__ import annotations
22

33
from collections.abc import Mapping
4-
from typing import TYPE_CHECKING, Literal, Self, TypedDict, TypeGuard, overload
4+
from typing import Literal, Self, TypedDict, TypeGuard, overload
55

66
from typing_extensions import ReadOnly
77

88
from zarr.codecs.numcodecs._codecs import (
99
_NumcodecsChecksumCodec,
1010
_warn_unstable_specification,
1111
)
12-
from zarr.core.common import CodecJSON, CodecJSON_V2, CodecJSON_V3, NamedConfig, ZarrFormat, _check_codecjson_v2, _check_codecjson_v3
13-
14-
if TYPE_CHECKING:
15-
pass
12+
from zarr.core.common import (
13+
CodecJSON,
14+
CodecJSON_V2,
15+
CodecJSON_V3,
16+
NamedConfig,
17+
ZarrFormat,
18+
_check_codecjson_v2,
19+
_check_codecjson_v3,
20+
)
1621

1722

1823
class Crc32Config(TypedDict):
@@ -26,6 +31,7 @@ class Crc32JSON_V2(Crc32Config):
2631

2732
id: ReadOnly[Literal["crc32"]]
2833

34+
2935
class Crc32JSON_V3_Legacy(NamedConfig[Literal["numcodecs.crc32"], Crc32Config]):
3036
"""Legacy JSON representation of CRC32 codec for Zarr V3."""
3137

@@ -81,7 +87,7 @@ def to_json(self, zarr_format: Literal[3]) -> Crc32JSON_V3: ...
8187
def to_json(self, zarr_format: ZarrFormat) -> Crc32JSON_V2 | Crc32JSON_V3:
8288
_warn_unstable_specification(self)
8389
return super().to_json(zarr_format) # type: ignore[return-value]
84-
90+
8591
@classmethod
8692
def _from_json_v2(cls, data: CodecJSON_V2) -> Self:
8793
return cls(**data)
@@ -97,4 +103,4 @@ def _from_json_v3(cls, data: CodecJSON_V3) -> Self:
97103
def from_json(cls, data: CodecJSON) -> Self:
98104
if _check_codecjson_v2(data):
99105
return cls._from_json_v2(data)
100-
return cls._from_json_v3(data)
106+
return cls._from_json_v3(data)

src/zarr/codecs/numcodecs/crc32c.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
class Crc32cJSON_V3_Legacy(NamedConfig[Literal["numcodecs.crc32c"], Crc32cConfig_V3]):
2626
"""Legacy JSON representation of Crc32c codec for Zarr V3."""
2727

28+
2829
def check_json_v2(data: object) -> TypeGuard[Crc32cJSON_V2]:
2930
"""
3031
A type guard for the Zarr V2 form of the CRC32C codec JSON
@@ -86,4 +87,4 @@ def _from_json_v3(cls, data: CodecJSON_V3) -> Self:
8687
def from_json(cls, data: CodecJSON) -> Self:
8788
if _check_codecjson_v2(data):
8889
return cls._from_json_v2(data)
89-
return cls._from_json_v3(data)
90+
return cls._from_json_v3(data)

src/zarr/codecs/numcodecs/fletcher32.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from collections.abc import Mapping
4-
from typing import TYPE_CHECKING, Literal, Self, TypedDict, TypeGuard, overload
4+
from typing import Literal, Self, TypedDict, TypeGuard, overload
55

66
from typing_extensions import ReadOnly
77

@@ -19,9 +19,6 @@
1919
_check_codecjson_v3,
2020
)
2121

22-
if TYPE_CHECKING:
23-
pass
24-
2522

2623
class Fletcher32Config(TypedDict):
2724
"""Configuration parameters for Fletcher32 codec."""
@@ -32,7 +29,10 @@ class Fletcher32JSON_V2(Fletcher32Config):
3229

3330
id: ReadOnly[Literal["fletcher32"]]
3431

35-
class Fletcher32JSON_V3_Legacy(NamedRequiredConfig[Literal["numcodecs.fletcher32"], Fletcher32Config]):
32+
33+
class Fletcher32JSON_V3_Legacy(
34+
NamedRequiredConfig[Literal["numcodecs.fletcher32"], Fletcher32Config]
35+
):
3636
"""Legacy JSON representation of Fletcher32 codec for Zarr V3."""
3737

3838

@@ -44,10 +44,7 @@ def check_json_v2(data: object) -> TypeGuard[Fletcher32JSON_V2]:
4444
"""
4545
A type guard for the Zarr V2 form of the Fletcher32 codec JSON
4646
"""
47-
return (
48-
_check_codecjson_v2(data)
49-
and data["id"] == "fletcher32"
50-
)
47+
return _check_codecjson_v2(data) and data["id"] == "fletcher32"
5148

5249

5350
def check_json_v3(data: object) -> TypeGuard[Fletcher32JSON_V3]:
@@ -96,4 +93,4 @@ def _from_json_v3(cls, data: CodecJSON_V3) -> Self:
9693
def from_json(cls, data: CodecJSON) -> Self:
9794
if _check_codecjson_v2(data):
9895
return cls._from_json_v2(data)
99-
return cls._from_json_v3(data)
96+
return cls._from_json_v3(data)

src/zarr/codecs/numcodecs/gzip.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ def check_json_v2(data: object) -> TypeGuard[GZipJSON_V2]:
3131
and 0 <= data["level"] <= 9
3232
)
3333

34+
3435
class GZipJSON_V3_Legacy(NamedRequiredConfig[Literal["numcodecs.gzip"], GZipConfig]):
3536
"""
3637
The JSON form of the GZip codec in Zarr V3.
3738
"""
3839

40+
3941
def check_json_v3(data: object) -> TypeGuard[GZipJSON_V3 | GZipJSON_V3_Legacy]:
4042
"""
4143
A type guard for the Zarr V3 form of the GZip codec JSON
@@ -84,4 +86,4 @@ def _from_json_v3(cls, data: CodecJSON_V3) -> Self:
8486
def from_json(cls, data: CodecJSON) -> Self:
8587
if _check_codecjson_v2(data):
8688
return cls._from_json_v2(data)
87-
return cls._from_json_v3(data)
89+
return cls._from_json_v3(data)

src/zarr/codecs/numcodecs/jenkins_lookup3.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from collections.abc import Mapping
4-
from typing import TYPE_CHECKING, Literal, Self, TypedDict, TypeGuard, overload
4+
from typing import Literal, Self, TypedDict, TypeGuard, overload
55

66
from typing_extensions import ReadOnly
77

@@ -19,9 +19,6 @@
1919
_check_codecjson_v3,
2020
)
2121

22-
if TYPE_CHECKING:
23-
pass
24-
2522

2623
class JenkinsLookup3Config(TypedDict):
2724
"""Configuration parameters for JenkinsLookup3 codec."""
@@ -35,7 +32,10 @@ class JenkinsLookup3JSON_V2(JenkinsLookup3Config):
3532

3633
id: ReadOnly[Literal["jenkins_lookup3"]]
3734

38-
class JenkinsLookup3JSON_V3_Legacy(NamedRequiredConfig[Literal["numcodecs.jenkins_lookup3"], JenkinsLookup3Config]):
35+
36+
class JenkinsLookup3JSON_V3_Legacy(
37+
NamedRequiredConfig[Literal["numcodecs.jenkins_lookup3"], JenkinsLookup3Config]
38+
):
3939
"""Legacy JSON representation of JenkinsLookup3 codec for Zarr V3."""
4040

4141

@@ -107,4 +107,4 @@ def _from_json_v3(cls, data: CodecJSON_V3) -> Self:
107107
def from_json(cls, data: CodecJSON) -> Self:
108108
if _check_codecjson_v2(data):
109109
return cls._from_json_v2(data)
110-
return cls._from_json_v3(data)
110+
return cls._from_json_v3(data)

src/zarr/codecs/numcodecs/lz4.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from collections.abc import Mapping
4-
from typing import TYPE_CHECKING, Literal, Self, TypedDict, TypeGuard, overload
4+
from typing import Literal, Self, TypedDict, TypeGuard, overload
55

66
from typing_extensions import ReadOnly
77

@@ -19,9 +19,6 @@
1919
_check_codecjson_v3,
2020
)
2121

22-
if TYPE_CHECKING:
23-
pass
24-
2522

2623
class LZ4Config(TypedDict):
2724
acceleration: int
@@ -36,6 +33,7 @@ class LZ4JSON_V2(LZ4Config):
3633
class LZ4JSON_V3_Legacy(NamedRequiredConfig[Literal["numcodecs.lz4"], LZ4Config]):
3734
"""Legacy JSON representation of LZ4 codec for Zarr V3."""
3835

36+
3937
class LZ4JSON_V3(NamedRequiredConfig[Literal["lz4"], LZ4Config]):
4038
"""JSON representation of LZ4 codec for Zarr V3."""
4139

@@ -102,4 +100,4 @@ def _from_json_v3(cls, data: CodecJSON_V3) -> Self:
102100
def from_json(cls, data: CodecJSON) -> Self:
103101
if _check_codecjson_v2(data):
104102
return cls._from_json_v2(data)
105-
return cls._from_json_v3(data)
103+
return cls._from_json_v3(data)

0 commit comments

Comments
 (0)