Skip to content

Commit 45984d7

Browse files
committed
avoid circular imports by importing lower-level routines exactly where needed
1 parent f087c56 commit 45984d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+273
-191
lines changed

examples/custom_dtype.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
import pytest
2323

2424
import zarr
25-
from zarr.core.common import JSON, ZarrFormat
2625
from zarr.core.dtype import ZDType, data_type_registry
2726
from zarr.core.dtype.common import (
2827
DataTypeValidationError,
2928
DTypeConfig_V2,
3029
DTypeJSON,
3130
check_dtype_spec_v2,
3231
)
32+
from zarr.core.types import JSON, ZarrFormat
3333

3434
# This is the int2 array data type
3535
int2_dtype_cls = type(np.dtype("int2"))

src/zarr/abc/codec.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from zarr.abc.metadata import Metadata
77
from zarr.core.buffer import Buffer, NDBuffer
8-
from zarr.core.common import ChunkCoords, concurrent_map
8+
from zarr.core.common import concurrent_map
99
from zarr.core.config import config
1010

1111
if TYPE_CHECKING:
@@ -18,6 +18,7 @@
1818
from zarr.core.dtype.wrapper import TBaseDType, TBaseScalar, ZDType
1919
from zarr.core.indexing import SelectorTuple
2020
from zarr.core.metadata import ArrayMetadata
21+
from zarr.core.types import ChunkCoords
2122

2223
__all__ = [
2324
"ArrayArrayCodec",

src/zarr/abc/metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
if TYPE_CHECKING:
77
from typing import Self
88

9-
from zarr.core.common import JSON
9+
from zarr.core.types import JSON
1010

1111
from dataclasses import dataclass, fields
1212

src/zarr/abc/store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from typing import Any, Self, TypeAlias
1717

1818
from zarr.core.buffer import Buffer, BufferPrototype
19-
from zarr.core.common import BytesLike
19+
from zarr.core.types import BytesLike
2020

2121
__all__ = ["ByteGetter", "ByteSetter", "Store", "set_or_delete"]
2222

src/zarr/api/asynchronous.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@
2222
from zarr.core.array_spec import ArrayConfigLike, parse_array_config
2323
from zarr.core.buffer import NDArrayLike
2424
from zarr.core.common import (
25-
JSON,
26-
AccessModeLiteral,
27-
ChunkCoords,
28-
DimensionNames,
29-
MemoryOrder,
30-
ZarrFormat,
3125
_default_zarr_format,
3226
_warn_write_empty_chunks_kwarg,
3327
)
@@ -57,6 +51,14 @@
5751
from zarr.abc.codec import Codec
5852
from zarr.core.buffer import NDArrayLikeOrScalar
5953
from zarr.core.chunk_key_encodings import ChunkKeyEncoding
54+
from zarr.core.types import (
55+
JSON,
56+
AccessModeLiteral,
57+
ChunkCoords,
58+
DimensionNames,
59+
MemoryOrder,
60+
ZarrFormat,
61+
)
6062
from zarr.storage import StoreLike
6163

6264
# TODO: this type could use some more thought

src/zarr/api/synchronous.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
from zarr.core.array_spec import ArrayConfigLike
3131
from zarr.core.buffer import NDArrayLike, NDArrayLikeOrScalar
3232
from zarr.core.chunk_key_encodings import ChunkKeyEncoding, ChunkKeyEncodingLike
33-
from zarr.core.common import (
33+
from zarr.core.dtype import ZDTypeLike
34+
from zarr.core.types import (
3435
JSON,
3536
AccessModeLiteral,
3637
ChunkCoords,
@@ -39,7 +40,6 @@
3940
ShapeLike,
4041
ZarrFormat,
4142
)
42-
from zarr.core.dtype import ZDTypeLike
4343
from zarr.storage import StoreLike
4444

4545
__all__ = [

src/zarr/codecs/blosc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from zarr.abc.codec import BytesBytesCodec
1414
from zarr.core.buffer.cpu import as_numpy_array_wrapper
15-
from zarr.core.common import JSON, parse_enum, parse_named_configuration
15+
from zarr.core.common import parse_enum, parse_named_configuration
1616
from zarr.core.dtype.common import HasItemSize
1717
from zarr.registry import register_codec
1818

@@ -21,6 +21,7 @@
2121

2222
from zarr.core.array_spec import ArraySpec
2323
from zarr.core.buffer import Buffer
24+
from zarr.core.types import JSON
2425

2526

2627
class BloscShuffle(Enum):

src/zarr/codecs/bytes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99

1010
from zarr.abc.codec import ArrayBytesCodec
1111
from zarr.core.buffer import Buffer, NDArrayLike, NDBuffer
12-
from zarr.core.common import JSON, parse_enum, parse_named_configuration
12+
from zarr.core.common import parse_enum, parse_named_configuration
1313
from zarr.core.dtype.common import HasEndianness
1414
from zarr.registry import register_codec
1515

1616
if TYPE_CHECKING:
1717
from typing import Self
1818

1919
from zarr.core.array_spec import ArraySpec
20+
from zarr.core.types import JSON
2021

2122

2223
class Endian(Enum):

src/zarr/codecs/crc32c_.py

Lines changed: 2 additions & 1 deletion
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.common import JSON, parse_named_configuration
11+
from zarr.core.common import parse_named_configuration
1212
from zarr.registry import register_codec
1313

1414
if TYPE_CHECKING:
1515
from typing import Self
1616

1717
from zarr.core.array_spec import ArraySpec
1818
from zarr.core.buffer import Buffer
19+
from zarr.core.types import JSON
1920

2021

2122
@dataclass(frozen=True)

src/zarr/codecs/gzip.py

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

99
from zarr.abc.codec import BytesBytesCodec
1010
from zarr.core.buffer.cpu import as_numpy_array_wrapper
11-
from zarr.core.common import JSON, parse_named_configuration
11+
from zarr.core.common import parse_named_configuration
1212
from zarr.registry import register_codec
1313

1414
if TYPE_CHECKING:
1515
from typing import Self
1616

1717
from zarr.core.array_spec import ArraySpec
1818
from zarr.core.buffer import Buffer
19+
from zarr.core.types import JSON
1920

2021

2122
def parse_gzip_level(data: JSON) -> int:

0 commit comments

Comments
 (0)