Skip to content

Commit 8cfaac8

Browse files
committed
Fix typing in test_object
1 parent 1fe910d commit 8cfaac8

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,14 +355,14 @@ module = [
355355
"tests.test_metadata.*",
356356
"tests.test_store.test_core",
357357
"tests.test_store.test_logging",
358+
"tests.test_store.test_object",
358359
]
359360
strict = false
360361

361362
# TODO: Move the next modules up to the strict = false section
362363
# and fix the errors
363364
[[tool.mypy.overrides]]
364365
module = [
365-
"tests.test_store.test_object",
366366
"tests.test_store.test_stateful",
367367
"tests.test_store.test_wrapper",
368368
"tests.test_group",

tests/test_store/test_object.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# ruff: noqa: E402
2-
from typing import Any
2+
from pathlib import Path
3+
from typing import TypedDict
34

45
import pytest
56

@@ -16,17 +17,22 @@
1617
from zarr.testing.store import StoreTests
1718

1819

20+
class StoreKwargs(TypedDict):
21+
store: LocalStore
22+
read_only: bool
23+
24+
1925
class TestObjectStore(StoreTests[ObjectStore, cpu.Buffer]):
2026
store_cls = ObjectStore
2127
buffer_cls = cpu.Buffer
2228

2329
@pytest.fixture
24-
def store_kwargs(self, tmpdir) -> dict[str, Any]:
25-
store = LocalStore(prefix=tmpdir)
30+
def store_kwargs(self, tmp_path: Path) -> StoreKwargs:
31+
store = LocalStore(prefix=tmp_path)
2632
return {"store": store, "read_only": False}
2733

2834
@pytest.fixture
29-
def store(self, store_kwargs: dict[str, str | bool]) -> ObjectStore:
35+
def store(self, store_kwargs: StoreKwargs) -> ObjectStore:
3036
return self.store_cls(**store_kwargs)
3137

3238
async def get(self, store: ObjectStore, key: str) -> Buffer:
@@ -48,10 +54,8 @@ def test_store_repr(self, store: ObjectStore) -> None:
4854
def test_store_supports_writes(self, store: ObjectStore) -> None:
4955
assert store.supports_writes
5056

51-
async def test_store_supports_partial_writes(self, store: ObjectStore) -> None:
57+
def test_store_supports_partial_writes(self, store: ObjectStore) -> None:
5258
assert not store.supports_partial_writes
53-
with pytest.raises(NotImplementedError):
54-
await store.set_partial_values([("foo", 0, b"\x01\x02\x03\x04")])
5559

5660
def test_store_supports_listing(self, store: ObjectStore) -> None:
5761
assert store.supports_listing
@@ -64,6 +68,7 @@ def test_store_equal(self, store: ObjectStore) -> None:
6468
new_memory_store = ObjectStore(MemoryStore())
6569
assert store != new_memory_store
6670
# Test equality against a read only store
71+
assert isinstance(store.store, LocalStore)
6772
new_local_store = ObjectStore(LocalStore(prefix=store.store.prefix), read_only=True)
6873
assert store != new_local_store
6974
# Test two memory stores cannot be equal
@@ -73,7 +78,7 @@ def test_store_equal(self, store: ObjectStore) -> None:
7378
def test_store_init_raises(self) -> None:
7479
"""Test __init__ raises appropriate error for improper store type"""
7580
with pytest.raises(TypeError):
76-
ObjectStore("path/to/store")
81+
ObjectStore("path/to/store") # type: ignore[arg-type]
7782

7883
async def test_store_getsize(self, store: ObjectStore) -> None:
7984
buf = cpu.Buffer.from_bytes(b"\x01\x02\x03\x04")
@@ -92,10 +97,10 @@ async def test_store_getsize_prefix(self, store: ObjectStore) -> None:
9297

9398

9499
@pytest.mark.slow_hypothesis
95-
def test_zarr_hierarchy():
100+
def test_zarr_hierarchy() -> None:
96101
sync_store = ObjectStore(MemoryStore())
97102

98103
def mk_test_instance_sync() -> ZarrHierarchyStateMachine:
99104
return ZarrHierarchyStateMachine(sync_store)
100105

101-
run_state_machine_as_test(mk_test_instance_sync)
106+
run_state_machine_as_test(mk_test_instance_sync) # type: ignore[no-untyped-call]

0 commit comments

Comments
 (0)