Skip to content

Commit 506c89b

Browse files
authored
Fix ruff check issues (#764)
* Used ruff check --fix * Fix ruff check issues with pytest.warn
1 parent 7a6fad3 commit 506c89b

File tree

5 files changed

+17
-20
lines changed

5 files changed

+17
-20
lines changed

numcodecs/abc.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,13 @@
2929
"""
3030

3131
from abc import ABC, abstractmethod
32-
from typing import Optional
3332

3433

3534
class Codec(ABC):
3635
"""Codec abstract base class."""
3736

3837
# override in sub-class
39-
codec_id: Optional[str] = None
38+
codec_id: str | None = None
4039
"""Codec identifier."""
4140

4241
@abstractmethod

numcodecs/checksum32.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import zlib
44
from contextlib import suppress
55
from types import ModuleType
6-
from typing import Literal, Optional
6+
from typing import Literal
77

88
import numpy as np
99
from typing_extensions import Buffer
@@ -12,7 +12,7 @@
1212
from .compat import ensure_contiguous_ndarray, ndarray_copy
1313
from .jenkins import jenkins_lookup3
1414

15-
_crc32c: Optional[ModuleType] = None
15+
_crc32c: ModuleType | None = None
1616
with suppress(ImportError):
1717
import crc32c as _crc32c # type: ignore[no-redef, unused-ignore]
1818

numcodecs/lzma.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from types import ModuleType
2-
from typing import Optional
32

4-
_lzma: Optional[ModuleType] = None
3+
_lzma: ModuleType | None = None
54
try:
65
import lzma as _lzma
76
except ImportError: # pragma: no cover

numcodecs/tests/test_zarr3.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ def test_generic_filter(
122122
],
123123
)
124124

125-
a[:, :] = data.copy()
126-
a = zarr.open_array(store / "generic", mode="r")
125+
a[:, :] = data.copy()
126+
a = zarr.open_array(store / "generic", mode="r")
127127
np.testing.assert_array_equal(data, a[:, :])
128128

129129

@@ -140,8 +140,8 @@ def test_generic_filter_bitround(store: StorePath):
140140
filters=[numcodecs.zarr3.BitRound(keepbits=3)],
141141
)
142142

143-
a[:, :] = data.copy()
144-
a = zarr.open_array(store / "generic_bitround", mode="r")
143+
a[:, :] = data.copy()
144+
a = zarr.open_array(store / "generic_bitround", mode="r")
145145
assert np.allclose(data, a[:, :], atol=0.1)
146146

147147

@@ -158,8 +158,8 @@ def test_generic_filter_quantize(store: StorePath):
158158
filters=[numcodecs.zarr3.Quantize(digits=3)],
159159
)
160160

161-
a[:, :] = data.copy()
162-
a = zarr.open_array(store / "generic_quantize", mode="r")
161+
a[:, :] = data.copy()
162+
a = zarr.open_array(store / "generic_quantize", mode="r")
163163
assert np.allclose(data, a[:, :], atol=0.001)
164164

165165

@@ -177,8 +177,8 @@ def test_generic_filter_packbits(store: StorePath):
177177
filters=[numcodecs.zarr3.PackBits()],
178178
)
179179

180-
a[:, :] = data.copy()
181-
a = zarr.open_array(store / "generic_packbits", mode="r")
180+
a[:, :] = data.copy()
181+
a = zarr.open_array(store / "generic_packbits", mode="r")
182182
np.testing.assert_array_equal(data, a[:, :])
183183

184184
with pytest.raises(ValueError, match=".*requires bool dtype.*"):
@@ -217,8 +217,8 @@ def test_generic_checksum(
217217
compressors=[codec_class()],
218218
)
219219

220-
a[:, :] = data.copy()
221-
a = zarr.open_array(store / "generic_checksum", mode="r")
220+
a[:, :] = data.copy()
221+
a = zarr.open_array(store / "generic_checksum", mode="r")
222222
np.testing.assert_array_equal(data, a[:, :])
223223

224224

@@ -267,8 +267,8 @@ def test_delta_astype(store: StorePath):
267267
],
268268
)
269269

270-
a[:, :] = data.copy()
271-
a = zarr.open_array(store / "generic", mode="r")
270+
a[:, :] = data.copy()
271+
a = zarr.open_array(store / "generic", mode="r")
272272
np.testing.assert_array_equal(data, a[:, :])
273273

274274

numcodecs/zfpy.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
from contextlib import suppress
33
from importlib.metadata import PackageNotFoundError, version
44
from types import ModuleType
5-
from typing import Optional
65

7-
_zfpy: Optional[ModuleType] = None
6+
_zfpy: ModuleType | None = None
87

98
_zfpy_version: tuple = ()
109
with suppress(PackageNotFoundError):

0 commit comments

Comments
 (0)