11from __future__ import annotations
22
33import inspect
4- import pathlib
54import re
65from typing import TYPE_CHECKING
76
87import zarr .codecs
98import zarr .storage
109
1110if TYPE_CHECKING :
12- import pathlib
1311 from collections .abc import Callable
12+ from pathlib import Path
1413
1514 from zarr .abc .store import Store
1615 from zarr .core .common import JSON , MemoryOrder , ZarrFormat
4544from zarr .storage ._utils import normalize_path
4645from zarr .testing .utils import gpu_test
4746
48- if TYPE_CHECKING :
49- from collections .abc import Callable
50- from pathlib import Path
51-
5247
5348def test_create (memory_store : Store ) -> None :
5449 store = memory_store
@@ -209,9 +204,7 @@ async def test_open_group(memory_store: MemoryStore) -> None:
209204
210205
211206@pytest .mark .parametrize ("zarr_format" , [None , 2 , 3 ])
212- async def test_open_group_unspecified_version (
213- tmpdir : pathlib .Path , zarr_format : ZarrFormat
214- ) -> None :
207+ async def test_open_group_unspecified_version (tmpdir : Path , zarr_format : ZarrFormat ) -> None :
215208 """Regression test for https://github.com/zarr-developers/zarr-python/issues/2175"""
216209
217210 # create a group with specified zarr format (could be 2, 3, or None)
@@ -272,7 +265,7 @@ def test_save_errors() -> None:
272265 zarr .save ("data/example.zarr" , a , mode = "w" )
273266
274267
275- def test_open_with_mode_r (tmp_path : pathlib . Path ) -> None :
268+ def test_open_with_mode_r (tmp_path : Path ) -> None :
276269 # 'r' means read only (must exist)
277270 with pytest .raises (FileNotFoundError ):
278271 zarr .open (store = tmp_path , mode = "r" )
@@ -288,7 +281,7 @@ def test_open_with_mode_r(tmp_path: pathlib.Path) -> None:
288281 z2 [:] = 3
289282
290283
291- def test_open_with_mode_r_plus (tmp_path : pathlib . Path ) -> None :
284+ def test_open_with_mode_r_plus (tmp_path : Path ) -> None :
292285 # 'r+' means read/write (must exist)
293286 with pytest .raises (FileNotFoundError ):
294287 zarr .open (store = tmp_path , mode = "r+" )
@@ -301,7 +294,7 @@ def test_open_with_mode_r_plus(tmp_path: pathlib.Path) -> None:
301294 z2 [:] = 3
302295
303296
304- async def test_open_with_mode_a (tmp_path : pathlib . Path ) -> None :
297+ async def test_open_with_mode_a (tmp_path : Path ) -> None :
305298 # Open without shape argument should default to group
306299 g = zarr .open (store = tmp_path , mode = "a" )
307300 assert isinstance (g , Group )
@@ -319,7 +312,7 @@ async def test_open_with_mode_a(tmp_path: pathlib.Path) -> None:
319312 z2 [:] = 3
320313
321314
322- def test_open_with_mode_w (tmp_path : pathlib . Path ) -> None :
315+ def test_open_with_mode_w (tmp_path : Path ) -> None :
323316 # 'w' means create (overwrite if exists);
324317 arr = zarr .open (store = tmp_path , mode = "w" , shape = (3 , 3 ))
325318 assert isinstance (arr , Array )
@@ -333,7 +326,7 @@ def test_open_with_mode_w(tmp_path: pathlib.Path) -> None:
333326 z2 [:] = 3
334327
335328
336- def test_open_with_mode_w_minus (tmp_path : pathlib . Path ) -> None :
329+ def test_open_with_mode_w_minus (tmp_path : Path ) -> None :
337330 # 'w-' means create (fail if exists)
338331 arr = zarr .open (store = tmp_path , mode = "w-" , shape = (3 , 3 ))
339332 assert isinstance (arr , Array )
@@ -405,7 +398,7 @@ def test_load_array(sync_store: Store) -> None:
405398
406399@pytest .mark .parametrize ("path" , ["data" , None ])
407400@pytest .mark .parametrize ("load_read_only" , [True , False , None ])
408- def test_load_zip (tmp_path : pathlib . Path , path : str | None , load_read_only : bool | None ) -> None :
401+ def test_load_zip (tmp_path : Path , path : str | None , load_read_only : bool | None ) -> None :
409402 file = tmp_path / "test.zip"
410403 data = np .arange (100 ).reshape (10 , 10 )
411404
@@ -423,7 +416,7 @@ def test_load_zip(tmp_path: pathlib.Path, path: str | None, load_read_only: bool
423416
424417@pytest .mark .parametrize ("path" , ["data" , None ])
425418@pytest .mark .parametrize ("load_read_only" , [True , False ])
426- def test_load_local (tmp_path : pathlib . Path , path : str | None , load_read_only : bool ) -> None :
419+ def test_load_local (tmp_path : Path , path : str | None , load_read_only : bool ) -> None :
427420 file = tmp_path / "test.zip"
428421 data = np .arange (100 ).reshape (10 , 10 )
429422
@@ -1139,7 +1132,7 @@ async def test_open_falls_back_to_open_group_async(zarr_format: ZarrFormat) -> N
11391132
11401133
11411134@pytest .mark .parametrize ("mode" , ["r" , "r+" , "w" , "a" ])
1142- def test_open_modes_creates_group (tmp_path : pathlib . Path , mode : str ) -> None :
1135+ def test_open_modes_creates_group (tmp_path : Path , mode : str ) -> None :
11431136 # https://github.com/zarr-developers/zarr-python/issues/2490
11441137 zarr_dir = tmp_path / f"mode-{ mode } -test.zarr"
11451138 if mode in ["r" , "r+" ]:
0 commit comments