1
1
import tempfile
2
+ from collections .abc import Callable , Coroutine
2
3
from pathlib import Path
3
4
4
5
import pytest
22
23
@pytest .mark .parametrize ("write_group" , [True , False ])
23
24
@pytest .mark .parametrize ("zarr_format" , [2 , 3 ])
24
25
async def test_contains_group (
25
- local_store , path : str , write_group : bool , zarr_format : ZarrFormat
26
+ local_store : LocalStore , path : str , write_group : bool , zarr_format : ZarrFormat
26
27
) -> None :
27
28
"""
28
29
Test that the contains_group method correctly reports the existence of a group.
@@ -38,7 +39,7 @@ async def test_contains_group(
38
39
@pytest .mark .parametrize ("write_array" , [True , False ])
39
40
@pytest .mark .parametrize ("zarr_format" , [2 , 3 ])
40
41
async def test_contains_array (
41
- local_store , path : str , write_array : bool , zarr_format : ZarrFormat
42
+ local_store : LocalStore , path : str , write_array : bool , zarr_format : ZarrFormat
42
43
) -> None :
43
44
"""
44
45
Test that the contains array method correctly reports the existence of an array.
@@ -51,13 +52,15 @@ async def test_contains_array(
51
52
52
53
53
54
@pytest .mark .parametrize ("func" , [contains_array , contains_group ])
54
- async def test_contains_invalid_format_raises (local_store , func : callable ) -> None :
55
+ async def test_contains_invalid_format_raises (
56
+ local_store : LocalStore , func : Callable [[StorePath , ZarrFormat ], Coroutine [None , None , bool ]]
57
+ ) -> None :
55
58
"""
56
59
Test contains_group and contains_array raise errors for invalid zarr_formats
57
60
"""
58
61
store_path = StorePath (local_store )
59
62
with pytest .raises (ValueError ):
60
- assert await func (store_path , zarr_format = "3.0" )
63
+ assert await func (store_path , "3.0" ) # type: ignore[arg-type]
61
64
62
65
63
66
@pytest .mark .parametrize ("path" , [None , "" , "bar" ])
@@ -110,12 +113,12 @@ async def test_make_store_path_store_path(
110
113
111
114
112
115
@pytest .mark .parametrize ("modes" , [(True , "w" ), (False , "x" )])
113
- async def test_store_path_invalid_mode_raises (tmpdir : LEGACY_PATH , modes : tuple ) -> None :
116
+ async def test_store_path_invalid_mode_raises (tmpdir : LEGACY_PATH , modes : tuple [ bool , str ] ) -> None :
114
117
"""
115
118
Test that ValueErrors are raise for invalid mode.
116
119
"""
117
120
with pytest .raises (ValueError ):
118
- await StorePath .open (LocalStore (str (tmpdir ), read_only = modes [0 ]), path = None , mode = modes [1 ])
121
+ await StorePath .open (LocalStore (str (tmpdir ), read_only = modes [0 ]), path = "" , mode = modes [1 ]) # type: ignore[arg-type]
119
122
120
123
121
124
async def test_make_store_path_invalid () -> None :
@@ -126,7 +129,7 @@ async def test_make_store_path_invalid() -> None:
126
129
await make_store_path (1 ) # type: ignore[arg-type]
127
130
128
131
129
- async def test_make_store_path_fsspec (monkeypatch ) -> None :
132
+ async def test_make_store_path_fsspec () -> None :
130
133
pytest .importorskip ("fsspec" )
131
134
pytest .importorskip ("requests" )
132
135
pytest .importorskip ("aiohttp" )
@@ -175,12 +178,12 @@ def test_normalize_path_upath() -> None:
175
178
assert normalize_path (upath .UPath ("foo/bar" )) == "foo/bar"
176
179
177
180
178
- def test_normalize_path_none ():
181
+ def test_normalize_path_none () -> None :
179
182
assert normalize_path (None ) == ""
180
183
181
184
182
185
@pytest .mark .parametrize ("path" , ["." , ".." ])
183
- def test_normalize_path_invalid (path : str ):
186
+ def test_normalize_path_invalid (path : str ) -> None :
184
187
with pytest .raises (ValueError ):
185
188
normalize_path (path )
186
189
@@ -221,7 +224,7 @@ def test_invalid(paths: tuple[str, str]) -> None:
221
224
_normalize_paths (paths )
222
225
223
226
224
- def test_normalize_path_keys ():
227
+ def test_normalize_path_keys () -> None :
225
228
"""
226
229
Test that ``_normalize_path_keys`` just applies the normalize_path function to each key of its
227
230
input
0 commit comments