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
4645from zarr .storage ._utils import normalize_path
4746from zarr .testing .utils import gpu_test
4847
49- if TYPE_CHECKING :
50- from collections .abc import Callable
51- from pathlib import Path
52-
5348
5449def test_create (memory_store : Store ) -> None :
5550 store = memory_store
@@ -210,9 +205,7 @@ async def test_open_group(memory_store: MemoryStore) -> None:
210205
211206
212207@pytest .mark .parametrize ("zarr_format" , [None , 2 , 3 ])
213- async def test_open_group_unspecified_version (
214- tmpdir : pathlib .Path , zarr_format : ZarrFormat
215- ) -> None :
208+ async def test_open_group_unspecified_version (tmpdir : Path , zarr_format : ZarrFormat ) -> None :
216209 """Regression test for https://github.com/zarr-developers/zarr-python/issues/2175"""
217210
218211 # create a group with specified zarr format (could be 2, 3, or None)
@@ -273,7 +266,7 @@ def test_save_errors() -> None:
273266 zarr .save ("data/example.zarr" , a , mode = "w" )
274267
275268
276- def test_open_with_mode_r (tmp_path : pathlib . Path ) -> None :
269+ def test_open_with_mode_r (tmp_path : Path ) -> None :
277270 # 'r' means read only (must exist)
278271 with pytest .raises (FileNotFoundError ):
279272 zarr .open (store = tmp_path , mode = "r" )
@@ -289,7 +282,7 @@ def test_open_with_mode_r(tmp_path: pathlib.Path) -> None:
289282 z2 [:] = 3
290283
291284
292- def test_open_with_mode_r_plus (tmp_path : pathlib . Path ) -> None :
285+ def test_open_with_mode_r_plus (tmp_path : Path ) -> None :
293286 # 'r+' means read/write (must exist)
294287 with pytest .raises (FileNotFoundError ):
295288 zarr .open (store = tmp_path , mode = "r+" )
@@ -302,7 +295,7 @@ def test_open_with_mode_r_plus(tmp_path: pathlib.Path) -> None:
302295 z2 [:] = 3
303296
304297
305- async def test_open_with_mode_a (tmp_path : pathlib . Path ) -> None :
298+ async def test_open_with_mode_a (tmp_path : Path ) -> None :
306299 # Open without shape argument should default to group
307300 g = zarr .open (store = tmp_path , mode = "a" )
308301 assert isinstance (g , Group )
@@ -320,7 +313,7 @@ async def test_open_with_mode_a(tmp_path: pathlib.Path) -> None:
320313 z2 [:] = 3
321314
322315
323- def test_open_with_mode_w (tmp_path : pathlib . Path ) -> None :
316+ def test_open_with_mode_w (tmp_path : Path ) -> None :
324317 # 'w' means create (overwrite if exists);
325318 arr = zarr .open (store = tmp_path , mode = "w" , shape = (3 , 3 ))
326319 assert isinstance (arr , Array )
@@ -334,7 +327,7 @@ def test_open_with_mode_w(tmp_path: pathlib.Path) -> None:
334327 z2 [:] = 3
335328
336329
337- def test_open_with_mode_w_minus (tmp_path : pathlib . Path ) -> None :
330+ def test_open_with_mode_w_minus (tmp_path : Path ) -> None :
338331 # 'w-' means create (fail if exists)
339332 arr = zarr .open (store = tmp_path , mode = "w-" , shape = (3 , 3 ))
340333 assert isinstance (arr , Array )
@@ -406,7 +399,7 @@ def test_load_array(sync_store: Store) -> None:
406399
407400@pytest .mark .parametrize ("path" , ["data" , None ])
408401@pytest .mark .parametrize ("load_read_only" , [True , False , None ])
409- def test_load_zip (tmp_path : pathlib . Path , path : str | None , load_read_only : bool | None ) -> None :
402+ def test_load_zip (tmp_path : Path , path : str | None , load_read_only : bool | None ) -> None :
410403 file = tmp_path / "test.zip"
411404 data = np .arange (100 ).reshape (10 , 10 )
412405
@@ -424,7 +417,7 @@ def test_load_zip(tmp_path: pathlib.Path, path: str | None, load_read_only: bool
424417
425418@pytest .mark .parametrize ("path" , ["data" , None ])
426419@pytest .mark .parametrize ("load_read_only" , [True , False ])
427- def test_load_local (tmp_path : pathlib . Path , path : str | None , load_read_only : bool ) -> None :
420+ def test_load_local (tmp_path : Path , path : str | None , load_read_only : bool ) -> None :
428421 file = tmp_path / "test.zip"
429422 data = np .arange (100 ).reshape (10 , 10 )
430423
@@ -1174,7 +1167,7 @@ async def test_open_falls_back_to_open_group_async(zarr_format: ZarrFormat) -> N
11741167
11751168
11761169@pytest .mark .parametrize ("mode" , ["r" , "r+" , "w" , "a" ])
1177- def test_open_modes_creates_group (tmp_path : pathlib . Path , mode : str ) -> None :
1170+ def test_open_modes_creates_group (tmp_path : Path , mode : str ) -> None :
11781171 # https://github.com/zarr-developers/zarr-python/issues/2490
11791172 zarr_dir = tmp_path / f"mode-{ mode } -test.zarr"
11801173 if mode in ["r" , "r+" ]:
0 commit comments