Skip to content

Commit b01e61c

Browse files
committed
Merge remote-tracking branch 'upstream/v3' into user/tom/fix/v2-compat
2 parents 784cb28 + e8800b0 commit b01e61c

40 files changed

+543
-131
lines changed

.pre-commit-config.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ repos:
2525
rev: v1.11.2
2626
hooks:
2727
- id: mypy
28-
files: src
28+
files: src|tests/v3/test_(api|array|buffer).py
2929
additional_dependencies:
3030
# Package dependencies
3131
- asciitree
@@ -35,7 +35,17 @@ repos:
3535
- numcodecs
3636
- numpy
3737
- typing_extensions
38+
- universal-pathlib
3839
# Tests
3940
- pytest
4041
# Zarr v2
4142
- types-redis
43+
- repo: https://github.com/scientific-python/cookie
44+
rev: 2024.04.23
45+
hooks:
46+
- id: sp-repo-review
47+
- repo: https://github.com/pre-commit/pygrep-hooks
48+
rev: v1.10.0
49+
hooks:
50+
- id: rst-directive-colons
51+
- id: rst-inline-touching-normal

pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ extra = [
9696
]
9797
optional = [
9898
'lmdb',
99+
'universal-pathlib',
99100
]
100101

101102
[project.urls]
@@ -213,6 +214,7 @@ extend-select = [
213214
"UP", # pyupgrade
214215
"RSE",
215216
"RUF",
217+
"TCH", # flake8-type-checking
216218
"TRY", # tryceratops
217219
]
218220
ignore = [
@@ -259,3 +261,9 @@ filterwarnings = [
259261
markers = [
260262
"gpu: mark a test as requiring CuPy and GPU"
261263
]
264+
265+
[tool.repo-review]
266+
ignore = [
267+
"PC111", # fix Python code in documentation - enable later
268+
"PC180", # for JavaScript - not interested
269+
]

src/zarr/abc/codec.py

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

33
from abc import abstractmethod
4-
from collections.abc import Awaitable, Callable, Iterable
54
from typing import TYPE_CHECKING, Any, Generic, TypeVar
65

7-
import numpy as np
8-
96
from zarr.abc.metadata import Metadata
10-
from zarr.abc.store import ByteGetter, ByteSetter
117
from zarr.core.buffer import Buffer, NDBuffer
12-
from zarr.core.chunk_grids import ChunkGrid
138
from zarr.core.common import ChunkCoords, concurrent_map
149
from zarr.core.config import config
1510

1611
if TYPE_CHECKING:
12+
from collections.abc import Awaitable, Callable, Iterable
13+
14+
import numpy as np
1715
from typing_extensions import Self
1816

17+
from zarr.abc.store import ByteGetter, ByteSetter
1918
from zarr.core.array_spec import ArraySpec
19+
from zarr.core.chunk_grids import ChunkGrid
2020
from zarr.core.common import JSON
2121
from zarr.core.indexing import SelectorTuple
2222

src/zarr/abc/metadata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
if TYPE_CHECKING:
77
from typing_extensions import Self
88

9-
from dataclasses import dataclass, fields
9+
from zarr.core.common import JSON
1010

11-
from zarr.core.common import JSON
11+
from dataclasses import dataclass, fields
1212

1313
__all__ = ["Metadata"]
1414

src/zarr/api/asynchronous.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@
22

33
import asyncio
44
import warnings
5-
from collections.abc import Iterable
6-
from typing import Any, Literal, Union, cast
5+
from typing import TYPE_CHECKING, Any, Literal, Union, cast
76

87
import numpy as np
98
import numpy.typing as npt
109

11-
from zarr.abc.codec import Codec
1210
from zarr.core.array import Array, AsyncArray
13-
from zarr.core.buffer import NDArrayLike
14-
from zarr.core.chunk_key_encodings import ChunkKeyEncoding
1511
from zarr.core.common import JSON, AccessModeLiteral, ChunkCoords, MemoryOrder, ZarrFormat
1612
from zarr.core.group import AsyncGroup
1713
from zarr.core.metadata import ArrayV2Metadata, ArrayV3Metadata
@@ -20,6 +16,13 @@
2016
make_store_path,
2117
)
2218

19+
if TYPE_CHECKING:
20+
from collections.abc import Iterable
21+
22+
from zarr.abc.codec import Codec
23+
from zarr.core.buffer import NDArrayLike
24+
from zarr.core.chunk_key_encodings import ChunkKeyEncoding
25+
2326
__all__ = [
2427
"consolidate_metadata",
2528
"copy",

src/zarr/api/synchronous.py

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

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

55
import zarr.api.asynchronous as async_api
66
from zarr._compat import _deprecate_positional_args
77
from zarr.core.array import Array, AsyncArray
8-
from zarr.core.buffer import NDArrayLike
9-
from zarr.core.common import JSON, AccessModeLiteral, ChunkCoords, ZarrFormat
108
from zarr.core.group import Group
119
from zarr.core.sync import sync
12-
from zarr.store import StoreLike
10+
11+
if TYPE_CHECKING:
12+
from zarr.core.buffer import NDArrayLike
13+
from zarr.core.common import JSON, AccessModeLiteral, ChunkCoords, ZarrFormat
14+
from zarr.store import StoreLike
1315

1416
__all__ = [
1517
"consolidate_metadata",

src/zarr/codecs/_v2.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
from __future__ import annotations
22

33
from dataclasses import dataclass
4+
from typing import TYPE_CHECKING
45

56
import numcodecs
67
from numcodecs.compat import ensure_bytes, ensure_ndarray
78

89
from zarr.abc.codec import ArrayArrayCodec, ArrayBytesCodec
9-
from zarr.core.array_spec import ArraySpec
1010
from zarr.core.buffer import Buffer, NDBuffer, default_buffer_prototype
1111
from zarr.core.common import JSON, to_thread
1212
from zarr.registry import get_ndbuffer_class
1313

14+
if TYPE_CHECKING:
15+
from zarr.core.array_spec import ArraySpec
16+
1417

1518
@dataclass(frozen=True)
1619
class V2Compressor(ArrayBytesCodec):

src/zarr/codecs/blosc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@
99
from numcodecs.blosc import Blosc
1010

1111
from zarr.abc.codec import BytesBytesCodec
12-
from zarr.core.array_spec import ArraySpec
13-
from zarr.core.buffer import Buffer
1412
from zarr.core.buffer.cpu import as_numpy_array_wrapper
1513
from zarr.core.common import JSON, parse_enum, parse_named_configuration, to_thread
1614
from zarr.registry import register_codec
1715

1816
if TYPE_CHECKING:
1917
from typing_extensions import Self
2018

19+
from zarr.core.array_spec import ArraySpec
20+
from zarr.core.buffer import Buffer
21+
2122

2223
class BloscShuffle(Enum):
2324
noshuffle = "noshuffle"

src/zarr/codecs/bytes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
import numpy as np
99

1010
from zarr.abc.codec import ArrayBytesCodec
11-
from zarr.core.array_spec import ArraySpec
1211
from zarr.core.buffer import Buffer, NDArrayLike, NDBuffer
1312
from zarr.core.common import JSON, parse_enum, parse_named_configuration
1413
from zarr.registry import register_codec
1514

1615
if TYPE_CHECKING:
1716
from typing_extensions import Self
1817

18+
from zarr.core.array_spec import ArraySpec
19+
1920

2021
class Endian(Enum):
2122
big = "big"

src/zarr/codecs/crc32c_.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
from crc32c import crc32c
99

1010
from zarr.abc.codec import BytesBytesCodec
11-
from zarr.core.array_spec import ArraySpec
12-
from zarr.core.buffer import Buffer
1311
from zarr.core.common import JSON, parse_named_configuration
1412
from zarr.registry import register_codec
1513

1614
if TYPE_CHECKING:
1715
from typing_extensions import Self
1816

17+
from zarr.core.array_spec import ArraySpec
18+
from zarr.core.buffer import Buffer
19+
1920

2021
@dataclass(frozen=True)
2122
class Crc32cCodec(BytesBytesCodec):

0 commit comments

Comments
 (0)