Skip to content

Commit

Permalink
Upgrade ruff to 0.9.1 (zarr-developers#2703)
Browse files Browse the repository at this point in the history
* Apply ruff rule RUF100

RUF100 Unused `noqa` directive (unused: `E402`)

Otherwise, latest ruff 0.9.1 complains.

* Enable ruff/flake8-implicit-str-concat rules ISC001 and ISC002

Starting with ruff 0.9.1, they are documented to be compatible with the
ruff formatter, if they are both enabled.

* Run `ruff format`

* Upgrade ruff to 0.9.1
  • Loading branch information
DimitriPapadopoulos authored Jan 16, 2025
1 parent cef2b24 commit 280daac
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ci:
default_stages: [pre-commit, pre-push]
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
rev: v0.9.1
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,6 @@ ignore = [
"Q003",
"COM812",
"COM819",
"ISC001",
"ISC002",
]

[tool.ruff.lint.extend-per-file-ignores]
Expand Down
6 changes: 3 additions & 3 deletions src/zarr/codecs/sharding.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ async def get(
self, prototype: BufferPrototype, byte_range: ByteRequest | None = None
) -> Buffer | None:
assert byte_range is None, "byte_range is not supported within shards"
assert (
prototype == default_buffer_prototype()
), f"prototype is not supported within shards currently. diff: {prototype} != {default_buffer_prototype()}"
assert prototype == default_buffer_prototype(), (
f"prototype is not supported within shards currently. diff: {prototype} != {default_buffer_prototype()}"
)
return self.shard_dict.get(self.chunk_coords)


Expand Down
6 changes: 3 additions & 3 deletions src/zarr/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,9 @@ def is_pure_orthogonal_indexing(selection: Selection, ndim: int) -> TypeGuard[Or
def get_chunk_shape(chunk_grid: ChunkGrid) -> ChunkCoords:
from zarr.core.chunk_grids import RegularChunkGrid

assert isinstance(
chunk_grid, RegularChunkGrid
), "Only regular chunk grid is supported, currently."
assert isinstance(chunk_grid, RegularChunkGrid), (
"Only regular chunk grid is supported, currently."
)
return chunk_grid.chunk_shape


Expand Down
6 changes: 3 additions & 3 deletions src/zarr/core/metadata/v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,9 @@ def inner_codecs(self) -> tuple[Codec, ...]:
def get_chunk_spec(
self, _chunk_coords: ChunkCoords, array_config: ArrayConfig, prototype: BufferPrototype
) -> ArraySpec:
assert isinstance(
self.chunk_grid, RegularChunkGrid
), "Currently, only regular chunk grid is supported"
assert isinstance(self.chunk_grid, RegularChunkGrid), (
"Currently, only regular chunk grid is supported"
)
return ArraySpec(
shape=self.chunk_grid.chunk_shape,
dtype=self.dtype,
Expand Down
8 changes: 4 additions & 4 deletions tests/test_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

pytest.importorskip("hypothesis")

import hypothesis.extra.numpy as npst # noqa: E402
import hypothesis.strategies as st # noqa: E402
from hypothesis import given # noqa: E402
import hypothesis.extra.numpy as npst
import hypothesis.strategies as st
from hypothesis import given

from zarr.testing.strategies import arrays, basic_indices, numpy_arrays, zarr_formats # noqa: E402
from zarr.testing.strategies import arrays, basic_indices, numpy_arrays, zarr_formats


@given(data=st.data(), zarr_format=zarr_formats)
Expand Down

0 comments on commit 280daac

Please sign in to comment.