diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 616243007..44fd44461 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,11 +10,11 @@ repos: - id: mixed-line-ending - repo: https://github.com/astral-sh/ruff-pre-commit - rev: 'v0.8.0' + rev: v0.15.1 hooks: - id: ruff-format - id: ruff - args: ["--fix", "--show-fixes", "icechunk-python/"] + args: ["icechunk-python/"] - repo: https://github.com/rhysd/actionlint rev: v1.7.8 diff --git a/icechunk-python/benchmarks/lib.py b/icechunk-python/benchmarks/lib.py index e71052dd0..ede30eba3 100644 --- a/icechunk-python/benchmarks/lib.py +++ b/icechunk-python/benchmarks/lib.py @@ -60,7 +60,7 @@ def get_task_chunk_shape( if c == s or left is None: task_chunk_shape.append(c) else: - q, r = divmod(s, c) + q, _ = divmod(s, c) if q > left: task_chunk_shape.append(left * c) else: diff --git a/icechunk-python/pyproject.toml b/icechunk-python/pyproject.toml index f91687169..5bce7fab0 100644 --- a/icechunk-python/pyproject.toml +++ b/icechunk-python/pyproject.toml @@ -27,7 +27,7 @@ dependencies = ["zarr>=3.1.0"] dev = [ { include-group = "test" }, "mypy", - "ruff", + "ruff==0.15.1", "maturin>=1.7,<2.0", "maturin-import-hook>=0.3.0", ] @@ -139,6 +139,8 @@ warn_unreachable = true enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"] [tool.ruff] +fix = true +show-fixes = true line-length = 90 extend-exclude = ["*.ipynb", "doc", "_typed_ops.pyi"] diff --git a/icechunk-python/python/icechunk/_icechunk_python.pyi b/icechunk-python/python/icechunk/_icechunk_python.pyi index e70216acf..fb4fe9919 100644 --- a/icechunk-python/python/icechunk/_icechunk_python.pyi +++ b/icechunk-python/python/icechunk/_icechunk_python.pyi @@ -2043,7 +2043,7 @@ class PyStore: async def getsize(self, key: str) -> int: ... async def getsize_prefix(self, prefix: str) -> int: ... -class PyAsyncStringGenerator(AsyncGenerator[str, None], metaclass=abc.ABCMeta): +class PyAsyncStringGenerator(AsyncGenerator[str], metaclass=abc.ABCMeta): def __aiter__(self) -> PyAsyncStringGenerator: ... async def __anext__(self) -> str: ... @@ -2082,7 +2082,7 @@ class SnapshotInfo: """ ... -class PyAsyncSnapshotGenerator(AsyncGenerator[SnapshotInfo, None], metaclass=abc.ABCMeta): +class PyAsyncSnapshotGenerator(AsyncGenerator[SnapshotInfo], metaclass=abc.ABCMeta): def __aiter__(self) -> PyAsyncSnapshotGenerator: ... async def __anext__(self) -> SnapshotInfo: ... diff --git a/icechunk-python/tests/test_config.py b/icechunk-python/tests/test_config.py index 912c33fab..a8b802ec7 100644 --- a/icechunk-python/tests/test_config.py +++ b/icechunk-python/tests/test_config.py @@ -311,6 +311,6 @@ def test_clear_virtual_chunk_containers_persists_through_reopen() -> None: # VCCs should be cleared after reopen reopened_vccs = repo.config.virtual_chunk_containers or {} - assert ( - reopened_vccs == {} - ), f"Expected no VCCs after reopen, got: {list(reopened_vccs.keys())}" + assert reopened_vccs == {}, ( + f"Expected no VCCs after reopen, got: {list(reopened_vccs.keys())}" + ) diff --git a/icechunk-python/tests/test_stateful_repo_ops.py b/icechunk-python/tests/test_stateful_repo_ops.py index b1052bade..24286b42c 100644 --- a/icechunk-python/tests/test_stateful_repo_ops.py +++ b/icechunk-python/tests/test_stateful_repo_ops.py @@ -290,9 +290,9 @@ def garbage_collect(self, older_than: datetime.datetime) -> set[str]: while commit_id != self.initial_snapshot_id: reachable_snaps.add(commit_id) parent_id = self.commits[commit_id].parent_id - assert ( - parent_id is not None - ), f"Commit {commit_id} has no parent but is not the initial snapshot" + assert parent_id is not None, ( + f"Commit {commit_id} has no parent but is not the initial snapshot" + ) commit_id = parent_id deleted = set() for k in set(self.ondisk_snaps) - reachable_snaps: @@ -410,9 +410,11 @@ def commit(self, message: str) -> str: # TODO: update changes made rule depending on result of # https://github.com/earth-mover/icechunk/issues/1532 @precondition( - lambda self: (self.model.changes_made) - and (self.repo.spec_version >= 2) - and len(self.model.commits) > 1 + lambda self: ( + (self.model.changes_made) + and (self.repo.spec_version >= 2) + and len(self.model.commits) > 1 + ) ) def amend(self, message: str) -> str: branch = self.session.branch @@ -634,16 +636,16 @@ def expire_snapshots( remaining_snapshot_ids.add(snap.id) expired_but_remaining = actual & remaining_snapshot_ids note(expired_but_remaining) - assert ( - not expired_but_remaining - ), f"Snapshots marked as expired but still in ancestry: {expired_but_remaining}" - - assert ( - actual_deleted_branches == expected.deleted_branches - ), f"deleted branches mismatch: actual={actual_deleted_branches}, expected={expected.deleted_branches}" - assert ( - actual_deleted_tags == expected.deleted_tags - ), f"deleted tags mismatch: actual={actual_deleted_tags}, expected={expected.deleted_tags}" + assert not expired_but_remaining, ( + f"Snapshots marked as expired but still in ancestry: {expired_but_remaining}" + ) + + assert actual_deleted_branches == expected.deleted_branches, ( + f"deleted branches mismatch: actual={actual_deleted_branches}, expected={expected.deleted_branches}" + ) + assert actual_deleted_tags == expected.deleted_tags, ( + f"deleted tags mismatch: actual={actual_deleted_tags}, expected={expected.deleted_tags}" + ) for branch in actual_deleted_branches: self.maybe_checkout_branch(branch) diff --git a/icechunk-python/tests/test_zarr/test_stateful.py b/icechunk-python/tests/test_zarr/test_stateful.py index b0746624b..d4b2a5a9c 100644 --- a/icechunk-python/tests/test_zarr/test_stateful.py +++ b/icechunk-python/tests/test_zarr/test_stateful.py @@ -100,8 +100,9 @@ def init_store(self, spec_version: int) -> None: super().init_store() @precondition( - lambda self: not self.store.session.has_uncommitted_changes - and bool(self.all_arrays) + lambda self: ( + not self.store.session.has_uncommitted_changes and bool(self.all_arrays) + ) ) @rule(data=st.data()) def reopen_with_config(self, data: st.DataObject) -> None: