Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion icechunk-python/benchmarks/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion icechunk-python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Expand Down Expand Up @@ -139,6 +139,8 @@ warn_unreachable = true
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]

[tool.ruff]
fix = true
show-fixes = true
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this standard in other projects? Isn't it weird having tools changing your code without you explicitly asking? I'm OK with if this is common.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm that is a good question actually. My goal here was to align pre-commit and manually running ruff, but after thinking about it, maybe this is a bad idea.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But FWIW pre-commit was already doing this!

line-length = 90
extend-exclude = ["*.ipynb", "doc", "_typed_ops.pyi"]

Expand Down
4 changes: 2 additions & 2 deletions icechunk-python/python/icechunk/_icechunk_python.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...

Expand Down Expand Up @@ -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: ...

Expand Down
6 changes: 3 additions & 3 deletions icechunk-python/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())}"
)
34 changes: 18 additions & 16 deletions icechunk-python/tests/test_stateful_repo_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions icechunk-python/tests/test_zarr/test_stateful.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down