1
- from abc import abstractmethod , ABC
1
+ from abc import ABC , abstractmethod
2
2
from collections .abc import AsyncGenerator
3
- from typing import List , Protocol , Tuple , Optional , runtime_checkable
3
+ from typing import Protocol , runtime_checkable
4
4
5
- from zarr .common import BytesLike
6
5
from zarr .buffer import Buffer
6
+ from zarr .common import BytesLike
7
7
8
8
9
9
class Store (ABC ):
10
10
@abstractmethod
11
11
async def get (
12
- self , key : str , byte_range : Optional [ Tuple [ int , Optional [ int ]]] = None
13
- ) -> Optional [ Buffer ] :
12
+ self , key : str , byte_range : tuple [ int , int | None ] | None = None
13
+ ) -> Buffer | None :
14
14
"""Retrieve the value associated with a given key.
15
15
16
16
Parameters
@@ -26,8 +26,8 @@ async def get(
26
26
27
27
@abstractmethod
28
28
async def get_partial_values (
29
- self , key_ranges : List [ Tuple [str , Tuple [int , int ]]]
30
- ) -> List [ Optional [ Buffer ] ]:
29
+ self , key_ranges : list [ tuple [str , tuple [int , int ]]]
30
+ ) -> list [ Buffer | None ]:
31
31
"""Retrieve possibly partial values from given key_ranges.
32
32
33
33
Parameters
@@ -150,18 +150,14 @@ def list_dir(self, prefix: str) -> AsyncGenerator[str, None]:
150
150
151
151
@runtime_checkable
152
152
class ByteGetter (Protocol ):
153
- async def get (
154
- self , byte_range : Optional [Tuple [int , Optional [int ]]] = None
155
- ) -> Optional [Buffer ]: ...
153
+ async def get (self , byte_range : tuple [int , int | None ] | None = None ) -> Buffer | None : ...
156
154
157
155
158
156
@runtime_checkable
159
157
class ByteSetter (Protocol ):
160
- async def get (
161
- self , byte_range : Optional [Tuple [int , Optional [int ]]] = None
162
- ) -> Optional [Buffer ]: ...
158
+ async def get (self , byte_range : tuple [int , int | None ] | None = None ) -> Buffer | None : ...
163
159
164
- async def set (self , value : Buffer , byte_range : Optional [ Tuple [ int , int ]] = None ) -> None : ...
160
+ async def set (self , value : Buffer , byte_range : tuple [ int , int ] | None = None ) -> None : ...
165
161
166
162
async def delete (self ) -> None : ...
167
163
0 commit comments