1+ from typing import Any
2+
13import numpy as np
24import pytest
35
46from zarr import Array
57from zarr .abc .store import Store
68from zarr .codecs import VLenUTF8Codec
7- from zarr .core .metadata .v3 import DataType
9+ from zarr .core .metadata .v3 import ArrayV3Metadata , DataType
810from zarr .store .common import StorePath
911
1012
1113@pytest .mark .parametrize ("store" , ["memory" , "local" ], indirect = ["store" ])
1214@pytest .mark .parametrize ("dtype" , [None , np .dtypes .StrDType ])
13- async def test_vlen_string (store : Store , dtype ) -> None :
15+ async def test_vlen_string (store : Store , dtype : None | np . dtype [ Any ] ) -> None :
1416 strings = ["hello" , "world" , "this" , "is" , "a" , "test" ]
1517 data = np .array (strings ).reshape ((2 , 3 ))
1618 if dtype is not None :
@@ -25,6 +27,7 @@ async def test_vlen_string(store: Store, dtype) -> None:
2527 fill_value = "" ,
2628 codecs = [VLenUTF8Codec ()],
2729 )
30+ assert isinstance (a .metadata , ArrayV3Metadata ) # needed for mypy
2831
2932 a [:, :] = data
3033 assert np .array_equal (data , a [:, :])
@@ -33,6 +36,7 @@ async def test_vlen_string(store: Store, dtype) -> None:
3336
3437 # test round trip
3538 b = Array .open (sp )
39+ assert isinstance (b .metadata , ArrayV3Metadata ) # needed for mypy
3640 assert np .array_equal (data , b [:, :])
3741 assert b .metadata .data_type == DataType .string
3842 assert b .dtype == np .dtypes .StringDType ()
0 commit comments