Skip to content

Commit 8e2c660

Browse files
Apply new ruff rules (preview mode) (#2235)
* Apply ruff/Pyflakes rule F841 F841 Local variable is assigned to but never used This issue is triggered in preview mode. * Apply ruff/flake8-pyi PYI059 PYI059 `Generic[]` should always be the last base class This future rule is triggered in preview mode. * Apply ruff rule RUF021 RUF021 Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear This future rule is triggered in preview mode. * Apply ruff rule RUF022 RUF022 `__all__` is not sorted This future rule is triggered in preview mode.
1 parent c52614a commit 8e2c660

File tree

15 files changed

+60
-60
lines changed

15 files changed

+60
-60
lines changed

src/zarr/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,13 @@
3434
assert not __version__.startswith("0.0.0")
3535

3636
__all__ = [
37-
"__version__",
38-
"config",
3937
"Array",
4038
"AsyncArray",
41-
"Group",
4239
"AsyncGroup",
43-
"tree",
40+
"Group",
41+
"__version__",
4442
"array",
43+
"config",
4544
"consolidate_metadata",
4645
"copy",
4746
"copy_all",
@@ -63,6 +62,7 @@
6362
"save",
6463
"save_array",
6564
"save_group",
65+
"tree",
6666
"zeros",
6767
"zeros_like",
6868
]

src/zarr/abc/codec.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@
2020
from zarr.core.indexing import SelectorTuple
2121

2222
__all__ = [
23-
"CodecInput",
24-
"CodecOutput",
2523
"ArrayArrayCodec",
2624
"ArrayBytesCodec",
27-
"BytesBytesCodec",
2825
"ArrayBytesCodecPartialDecodeMixin",
2926
"ArrayBytesCodecPartialEncodeMixin",
27+
"BytesBytesCodec",
28+
"CodecInput",
29+
"CodecOutput",
3030
"CodecPipeline",
3131
]
3232

3333
CodecInput = TypeVar("CodecInput", bound=NDBuffer | Buffer)
3434
CodecOutput = TypeVar("CodecOutput", bound=NDBuffer | Buffer)
3535

3636

37-
class _Codec(Generic[CodecInput, CodecOutput], Metadata):
37+
class _Codec(Metadata, Generic[CodecInput, CodecOutput]):
3838
"""Generic base class for codecs.
3939
Please use ArrayArrayCodec, ArrayBytesCodec or BytesBytesCodec for subclassing.
4040

src/zarr/abc/store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from zarr.core.buffer import Buffer, BufferPrototype
1515
from zarr.core.common import AccessModeLiteral, BytesLike
1616

17-
__all__ = ["Store", "AccessMode", "ByteGetter", "ByteSetter", "set_or_delete"]
17+
__all__ = ["AccessMode", "ByteGetter", "ByteSetter", "Store", "set_or_delete"]
1818

1919
ByteRangeRequest: TypeAlias = tuple[int | None, int | None]
2020

src/zarr/api/asynchronous.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,29 @@
3030
PathLike = str
3131

3232
__all__ = [
33+
"array",
3334
"consolidate_metadata",
3435
"copy",
3536
"copy_all",
3637
"copy_store",
37-
"load",
38-
"open",
39-
"open_consolidated",
40-
"save",
41-
"save_array",
42-
"save_group",
43-
"tree",
44-
"array",
45-
"group",
46-
"open_group",
4738
"create",
4839
"empty",
4940
"empty_like",
5041
"full",
5142
"full_like",
43+
"group",
44+
"load",
5245
"ones",
5346
"ones_like",
47+
"open",
5448
"open_array",
49+
"open_consolidated",
50+
"open_group",
5551
"open_like",
52+
"save",
53+
"save_array",
54+
"save_group",
55+
"tree",
5656
"zeros",
5757
"zeros_like",
5858
]

src/zarr/api/synchronous.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,29 @@
1414
from zarr.store import StoreLike
1515

1616
__all__ = [
17+
"array",
1718
"consolidate_metadata",
1819
"copy",
1920
"copy_all",
2021
"copy_store",
21-
"load",
22-
"open",
23-
"open_consolidated",
24-
"save",
25-
"save_array",
26-
"save_group",
27-
"tree",
28-
"array",
29-
"group",
30-
"open_group",
3122
"create",
3223
"empty",
3324
"empty_like",
3425
"full",
3526
"full_like",
27+
"group",
28+
"load",
3629
"ones",
3730
"ones_like",
31+
"open",
3832
"open_array",
33+
"open_consolidated",
34+
"open_group",
3935
"open_like",
36+
"save",
37+
"save_array",
38+
"save_group",
39+
"tree",
4040
"zeros",
4141
"zeros_like",
4242
]

src/zarr/convenience.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515
)
1616

1717
__all__ = [
18+
"consolidate_metadata",
19+
"copy",
20+
"copy_all",
21+
"copy_store",
22+
"load",
1823
"open",
24+
"open_consolidated",
1925
"save",
20-
"load",
2126
"save_array",
2227
"save_group",
23-
"copy",
24-
"copy_all",
25-
"copy_store",
2628
"tree",
27-
"consolidate_metadata",
28-
"open_consolidated",
2929
]
3030

3131
warnings.warn(

src/zarr/core/array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
from zarr.core.metadata.common import ArrayMetadata
7575

7676
# Array and AsyncArray are defined in the base ``zarr`` namespace
77-
__all__ = ["parse_array_metadata", "create_codec_pipeline"]
77+
__all__ = ["create_codec_pipeline", "parse_array_metadata"]
7878

7979

8080
def parse_array_metadata(data: Any) -> ArrayV2Metadata | ArrayV3Metadata:

src/zarr/core/buffer/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
__all__ = [
1212
"ArrayLike",
1313
"Buffer",
14+
"BufferPrototype",
1415
"NDArrayLike",
1516
"NDBuffer",
16-
"BufferPrototype",
1717
"default_buffer_prototype",
1818
"numpy_buffer_prototype",
1919
]

src/zarr/core/buffer/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def all_equal(self, other: Any, equal_nan: bool = True) -> bool:
467467
# Handle None fill_value for Zarr V2
468468
return False
469469
# use array_equal to obtain equal_nan=True functionality
470-
data, other = np.broadcast_arrays(self._data, other)
470+
_data, other = np.broadcast_arrays(self._data, other)
471471
return np.array_equal(
472472
self._data, other, equal_nan=equal_nan if self._data.dtype.kind not in "US" else False
473473
)

src/zarr/creation.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@
1616
)
1717

1818
__all__ = [
19+
"array",
1920
"create",
2021
"empty",
21-
"zeros",
22-
"ones",
23-
"full",
24-
"array",
25-
"open_array",
2622
"empty_like",
27-
"zeros_like",
28-
"ones_like",
23+
"full",
2924
"full_like",
25+
"ones",
26+
"ones_like",
27+
"open_array",
3028
"open_like",
29+
"zeros",
30+
"zeros_like",
3131
]
3232

3333
warnings.warn(

0 commit comments

Comments
 (0)