Skip to content

Commit 05ba029

Browse files
Multiple imports for an import name
1 parent ea4d7e9 commit 05ba029

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

tests/package_with_entrypoint/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import TYPE_CHECKING, Any, Literal, Self
3+
from typing import TYPE_CHECKING
44

55
import numpy as np
66
import numpy.typing as npt
@@ -14,7 +14,7 @@
1414

1515
if TYPE_CHECKING:
1616
from collections.abc import Iterable
17-
from typing import ClassVar, Literal
17+
from typing import Any, ClassVar, Literal, Self
1818

1919
from zarr.core.array_spec import ArraySpec
2020
from zarr.core.common import ZarrFormat

tests/test_api.py

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
from __future__ import annotations
22

33
import inspect
4-
import pathlib
54
import re
65
from typing import TYPE_CHECKING
76

87
import zarr.codecs
98
import zarr.storage
109

1110
if 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
@@ -46,10 +45,6 @@
4645
from zarr.storage._utils import normalize_path
4746
from zarr.testing.utils import gpu_test
4847

49-
if TYPE_CHECKING:
50-
from collections.abc import Callable
51-
from pathlib import Path
52-
5348

5449
def 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

Comments
 (0)