Skip to content

Commit 91f0c2c

Browse files
committed
apply PR feedback
1 parent b9d8177 commit 91f0c2c

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

zarr/_storage/store.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from collections.abc import MutableMapping
55
from copy import copy
66
from string import ascii_letters, digits
7-
from typing import Any, List, Mapping, Optional, Union
7+
from typing import Any, Dict, List, Mapping, Optional, Sequence, Tuple, Union
88

99
from zarr.meta import Metadata2, Metadata3
1010
from zarr.util import normalize_storage_path
@@ -261,10 +261,14 @@ def rmdir(self, path=None):
261261
"""Remove a data path and all its subkeys and related metadata.
262262
Expects a path without the data or meta root prefix."""
263263

264+
@property
264265
def supports_efficient_get_partial_values(self):
265266
return False
266267

267-
def get_partial_values(self, key_ranges):
268+
def get_partial_values(
269+
self,
270+
key_ranges: Sequence[Tuple[str, Tuple[int, Optional[int]]]]
271+
) -> List[Union[bytes, memoryview, bytearray]]:
268272
"""Get multiple partial values.
269273
key_ranges can be an iterable of key, range pairs,
270274
where a range specifies two integers range_start and range_length
@@ -274,8 +278,12 @@ def get_partial_values(self, key_ranges):
274278
from the end of the file.
275279
A key may occur multiple times with different ranges.
276280
Inserts None for missing keys into the returned list."""
277-
results = [None] * len(key_ranges)
278-
indexed_ranges_by_key = defaultdict(list)
281+
results: List[Union[bytes, memoryview, bytearray]] = (
282+
[None] * len(key_ranges) # type: ignore[list-item]
283+
)
284+
indexed_ranges_by_key: Dict[str, List[Tuple[int, Tuple[int, Optional[int]]]]] = (
285+
defaultdict(list)
286+
)
279287
for i, (key, range_) in enumerate(key_ranges):
280288
indexed_ranges_by_key[key].append((i, range_))
281289
for key, indexed_ranges in indexed_ranges_by_key.items():
@@ -504,8 +512,9 @@ def __iter__(self):
504512
def __len__(self):
505513
return self.inner_store.__len__()
506514

515+
@property
507516
def supports_efficient_get_partial_values(self):
508-
return self.inner_store.supports_efficient_get_partial_values()
517+
return self.inner_store.supports_efficient_get_partial_values
509518

510519
def get_partial_values(self, key_ranges):
511520
return self.inner_store.get_partial_values(key_ranges)

zarr/tests/test_storage_v3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def test_rename_nonexisting(self):
256256

257257
def test_get_partial_values(self):
258258
store = self.create_store()
259-
store.supports_efficient_get_partial_values()
259+
store.supports_efficient_get_partial_values in [True, False]
260260
store[data_root + 'foo'] = b'abcdefg'
261261
store[data_root + 'baz'] = b'z'
262262
assert [b'a'] == store.get_partial_values(

0 commit comments

Comments
 (0)