@@ -266,7 +266,7 @@ def __init__(
266266 if isinstance (metadata , dict ):
267267 zarr_format = metadata ["zarr_format" ]
268268 # TODO: remove this when we extensively type the dict representation of metadata
269- _metadata = cast (dict [str , JSON ], metadata )
269+ _metadata = cast (" dict[str, JSON]" , metadata )
270270 if zarr_format == 2 :
271271 metadata = ArrayV2Metadata .from_dict (_metadata )
272272 elif zarr_format == 3 :
@@ -895,7 +895,7 @@ async def open(
895895 store_path = await make_store_path (store )
896896 metadata_dict = await get_array_metadata (store_path , zarr_format = zarr_format )
897897 # TODO: remove this cast when we have better type hints
898- _metadata_dict = cast (ArrayV3MetadataDict , metadata_dict )
898+ _metadata_dict = cast (" ArrayV3MetadataDict" , metadata_dict )
899899 return cls (store_path = store_path , metadata = _metadata_dict )
900900
901901 @property
@@ -1386,7 +1386,7 @@ async def _set_selection(
13861386 if isinstance (array_like , np ._typing ._SupportsArrayFunc ):
13871387 # TODO: need to handle array types that don't support __array_function__
13881388 # like PyTorch and JAX
1389- array_like_ = cast (np ._typing ._SupportsArrayFunc , array_like )
1389+ array_like_ = cast (" np._typing._SupportsArrayFunc" , array_like )
13901390 value = np .asanyarray (value , dtype = self .metadata .dtype , like = array_like_ )
13911391 else :
13921392 if not hasattr (value , "shape" ):
@@ -1400,7 +1400,7 @@ async def _set_selection(
14001400 value = value .astype (dtype = self .metadata .dtype , order = "A" )
14011401 else :
14021402 value = np .array (value , dtype = self .metadata .dtype , order = "A" )
1403- value = cast (NDArrayLike , value )
1403+ value = cast (" NDArrayLike" , value )
14041404 # We accept any ndarray like object from the user and convert it
14051405 # to a NDBuffer (or subclass). From this point onwards, we only pass
14061406 # Buffer and NDBuffer between components.
@@ -2420,11 +2420,11 @@ def __getitem__(self, selection: Selection) -> NDArrayLike:
24202420 """
24212421 fields , pure_selection = pop_fields (selection )
24222422 if is_pure_fancy_indexing (pure_selection , self .ndim ):
2423- return self .vindex [cast (CoordinateSelection | MaskSelection , selection )]
2423+ return self .vindex [cast (" CoordinateSelection | MaskSelection" , selection )]
24242424 elif is_pure_orthogonal_indexing (pure_selection , self .ndim ):
24252425 return self .get_orthogonal_selection (pure_selection , fields = fields )
24262426 else :
2427- return self .get_basic_selection (cast (BasicSelection , pure_selection ), fields = fields )
2427+ return self .get_basic_selection (cast (" BasicSelection" , pure_selection ), fields = fields )
24282428
24292429 def __setitem__ (self , selection : Selection , value : npt .ArrayLike ) -> None :
24302430 """Modify data for an item or region of the array.
@@ -2519,11 +2519,11 @@ def __setitem__(self, selection: Selection, value: npt.ArrayLike) -> None:
25192519 """
25202520 fields , pure_selection = pop_fields (selection )
25212521 if is_pure_fancy_indexing (pure_selection , self .ndim ):
2522- self .vindex [cast (CoordinateSelection | MaskSelection , selection )] = value
2522+ self .vindex [cast (" CoordinateSelection | MaskSelection" , selection )] = value
25232523 elif is_pure_orthogonal_indexing (pure_selection , self .ndim ):
25242524 self .set_orthogonal_selection (pure_selection , value , fields = fields )
25252525 else :
2526- self .set_basic_selection (cast (BasicSelection , pure_selection ), value , fields = fields )
2526+ self .set_basic_selection (cast (" BasicSelection" , pure_selection ), value , fields = fields )
25272527
25282528 @_deprecate_positional_args
25292529 def get_basic_selection (
@@ -3641,7 +3641,7 @@ def update_attributes(self, new_attributes: dict[str, JSON]) -> Array:
36413641 # TODO: remove this cast when type inference improves
36423642 new_array = sync (self ._async_array .update_attributes (new_attributes ))
36433643 # TODO: remove this cast when type inference improves
3644- _new_array = cast (AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ], new_array )
3644+ _new_array = cast (" AsyncArray[ArrayV2Metadata] | AsyncArray[ArrayV3Metadata]" , new_array )
36453645 return type (self )(_new_array )
36463646
36473647 def __repr__ (self ) -> str :
@@ -3964,7 +3964,7 @@ async def init_array(
39643964 serializer = serializer ,
39653965 dtype = dtype_parsed ,
39663966 )
3967- sub_codecs = cast (tuple [Codec , ...], (* array_array , array_bytes , * bytes_bytes ))
3967+ sub_codecs = cast (" tuple[Codec, ...]" , (* array_array , array_bytes , * bytes_bytes ))
39683968 codecs_out : tuple [Codec , ...]
39693969 if shard_shape_parsed is not None :
39703970 index_location = None
@@ -4308,7 +4308,7 @@ def _parse_chunk_encoding_v3(
43084308 if isinstance (filters , dict | Codec ):
43094309 maybe_array_array = (filters ,)
43104310 else :
4311- maybe_array_array = cast (Iterable [Codec | dict [str , JSON ]], filters )
4311+ maybe_array_array = cast (" Iterable[Codec | dict[str, JSON]]" , filters )
43124312 out_array_array = tuple (_parse_array_array_codec (c ) for c in maybe_array_array )
43134313
43144314 if serializer == "auto" :
@@ -4325,7 +4325,7 @@ def _parse_chunk_encoding_v3(
43254325 if isinstance (compressors , dict | Codec ):
43264326 maybe_bytes_bytes = (compressors ,)
43274327 else :
4328- maybe_bytes_bytes = cast (Iterable [Codec | dict [str , JSON ]], compressors )
4328+ maybe_bytes_bytes = cast (" Iterable[Codec | dict[str, JSON]]" , compressors )
43294329
43304330 out_bytes_bytes = tuple (_parse_bytes_bytes_codec (c ) for c in maybe_bytes_bytes )
43314331
0 commit comments