11from __future__ import annotations
22
33from collections .abc import Mapping
4- from typing import Any , Literal , TypedDict , get_args
4+ from typing import Any , Literal , NotRequired , get_args
55
66import pytest
7- from typing_extensions import ReadOnly
7+ from typing_extensions import ReadOnly , TypedDict
88
99from src .zarr .core .type_check import check_type
1010from zarr .core .common import NamedConfig
@@ -45,7 +45,7 @@ def test_int_invalid() -> None:
4545 """
4646 result = check_type ("oops" , int )
4747 assert not result .success
48- #assert "expected int but got str" in result.errors[0]
48+ # assert "expected int but got str" in result.errors[0]
4949
5050
5151def test_float_valid () -> None :
@@ -62,7 +62,7 @@ def test_float_invalid() -> None:
6262 """
6363 result = check_type ("oops" , float )
6464 assert not result .success
65- #assert "expected float but got str" in result.errors[0]
65+ # assert "expected float but got str" in result.errors[0]
6666
6767
6868def test_tuple_valid () -> None :
@@ -79,7 +79,7 @@ def test_tuple_invalid() -> None:
7979 """
8080 result = check_type ((1 , "x" , 5 ), tuple [int , str , None ])
8181 assert not result .success
82- #assert "expected None but got int" in result.errors[0]
82+ # assert "expected None but got int" in result.errors[0]
8383
8484
8585def test_list_valid () -> None :
@@ -96,7 +96,7 @@ def test_list_invalid() -> None:
9696 """
9797 result = check_type ([1 , "oops" , 3 ], list [int ])
9898 assert not result .success
99- #assert "expected int but got str" in result.errors[0]
99+ # assert "expected int but got str" in result.errors[0]
100100
101101
102102def test_dict_valid () -> None :
@@ -113,7 +113,7 @@ def test_dict_invalid() -> None:
113113 """
114114 result = check_type ({"a" : 1 , "b" : "oops" }, dict [str , int ])
115115 assert not result .success
116- #assert "expected int but got str" in result.errors[0]
116+ # assert "expected int but got str" in result.errors[0]
117117
118118
119119def test_dict_any_valid () -> None :
@@ -150,7 +150,7 @@ def test_typeddict_invalid() -> None:
150150 }
151151 result = check_type (bad_user , User )
152152 assert not result .success
153- #assert "expected int but got str" in "".join(result.errors)
153+ # assert "expected int but got str" in "".join(result.errors)
154154
155155
156156def test_typeddict_fail_missing_required () -> None :
@@ -198,7 +198,7 @@ def test_literal_invalid() -> None:
198198 """
199199 Test that values not in a Literal fail type checking.
200200 """
201- typ = Literal [2 ,3 ]
201+ typ = Literal [2 , 3 ]
202202 val = 1
203203 result = check_type (val , typ )
204204 assert not result .success
@@ -254,8 +254,8 @@ class TimeConfig(TypedDict):
254254 result = check_type (data , DateTime64JSON_V3 )
255255 assert result .success
256256
257+
257258def test_zarr_v2_metadata () -> None :
258- from typing import NotRequired
259259 class ArrayMetadataJSON_V3 (TypedDict ):
260260 """
261261 A typed dictionary model for zarr v3 metadata.
@@ -277,8 +277,8 @@ class ArrayMetadataJSON_V3(TypedDict):
277277 "zarr_format" : 3 ,
278278 "node_type" : "array" ,
279279 "chunk_key_encoding" : {"name" : "default" , "configuration" : {"separator" : "." }},
280- "shape" : (10 ,10 ),
281- "chunk_grid" : {"name" : "regular" , "configuration" : {"chunk_shape" : (5 ,5 )}},
280+ "shape" : (10 , 10 ),
281+ "chunk_grid" : {"name" : "regular" , "configuration" : {"chunk_shape" : (5 , 5 )}},
282282 "codecs" : ("bytes" ,),
283283 "attributes" : {"a" : 1 , "b" : 2 },
284284 "data_type" : "uint8" ,
0 commit comments