Skip to content

Commit afc52dc

Browse files
committed
fix(zarr-indexing): satisfy lint rules CI enables and the pinned ruff does not
CI's ruff runs a broader rule set than the version pinned in .pre-commit-config.yaml, so three violations passed locally and failed there. All three are worth fixing on their own terms rather than suppressing. The BadIndex fixtures return 2.5 from __index__ deliberately — the point is an object that violates the protocol, so the package can be shown rejecting it. PLE0305 reads that as a mistake. keeps the runtime lie the test needs while saying the lie is intentional, and drops the type: ignore it needed for mypy. The stateful test imported ; is the form the rest of the suite uses, and the import block re-sorts around it. Assisted-by: ClaudeCode:claude-fable-5
1 parent d76f55c commit afc52dc

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

‎packages/zarr-indexing/tests/test_lazy_array.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import pickle
1515
from concurrent.futures import ThreadPoolExecutor
1616
from dataclasses import replace
17-
from typing import TYPE_CHECKING, Any
17+
from typing import TYPE_CHECKING, Any, cast
1818

1919
import numpy as np
2020
import pytest
@@ -62,8 +62,10 @@ def __int__(self) -> int:
6262

6363

6464
class BadIndex:
65+
"""An `__index__` that lies: the protocol requires an integer."""
66+
6567
def __index__(self) -> int:
66-
return 2.5 # type: ignore[return-value]
68+
return cast("int", 2.5)
6769

6870

6971
def reference() -> np.ndarray[Any, np.dtype[np.int64]]:

‎packages/zarr-indexing/tests/test_lazy_array_stateful.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
import pytest
2727
from hypothesis import settings
2828

29-
import zarr_indexing.testing.stateful as stateful
3029
from zarr_indexing import LazyArray, ReadContext
3130
from zarr_indexing.reader import basic_reader, numpy_reader
3231
from zarr_indexing.testing import (
3332
DEFAULT_SETTINGS,
3433
ChainedIndexingStateMachine,
3534
state_machine_test,
35+
stateful,
3636
)
3737

3838

‎packages/zarr-indexing/tests/test_transform.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22

3+
from typing import cast
4+
35
import numpy as np
46
import pytest
57

@@ -28,8 +30,10 @@ def __int__(self) -> int:
2830

2931

3032
class BadIndex:
33+
"""An `__index__` that lies: the protocol requires an integer."""
34+
3135
def __index__(self) -> int:
32-
return 2.5 # type: ignore[return-value]
36+
return cast("int", 2.5)
3337

3438

3539
class TestIndexTransformConstruction:

0 commit comments

Comments
 (0)