Skip to content

Commit ee677f9

Browse files
committed
clean up type hints
1 parent 63fd54b commit ee677f9

8 files changed

Lines changed: 129 additions & 135 deletions

File tree

src/zarr/api/asynchronous.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
Array,
1616
AsyncArray,
1717
CompressorLike,
18+
FilterLike,
1819
create_array,
1920
from_array,
2021
get_array_metadata,
@@ -46,8 +47,6 @@
4647
if TYPE_CHECKING:
4748
from collections.abc import Iterable
4849

49-
import numcodecs.abc
50-
5150
from zarr.abc.codec import Codec
5251
from zarr.core.buffer import NDArrayLikeOrScalar
5352
from zarr.core.chunk_key_encodings import ChunkKeyEncoding
@@ -863,15 +862,15 @@ async def create(
863862
*, # Note: this is a change from v2
864863
chunks: ChunkCoords | int | bool | None = None,
865864
dtype: ZDTypeLike | None = None,
866-
compressor: CompressorLike = "auto",
865+
compressor: CompressorLike | None | Literal["auto"] = "auto",
867866
fill_value: Any | None = DEFAULT_FILL_VALUE,
868867
order: MemoryOrder | None = None,
869868
store: str | StoreLike | None = None,
870869
synchronizer: Any | None = None,
871870
overwrite: bool = False,
872871
path: PathLike | None = None,
873872
chunk_store: StoreLike | None = None,
874-
filters: Iterable[dict[str, JSON] | numcodecs.abc.Codec] | None = None,
873+
filters: Iterable[FilterLike] | None = None,
875874
cache_metadata: bool | None = None,
876875
cache_attrs: bool | None = None,
877876
read_only: bool | None = None,

src/zarr/api/synchronous.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,21 @@
66

77
import zarr.api.asynchronous as async_api
88
import zarr.core.array
9-
from zarr.core.array import DEFAULT_FILL_VALUE, Array, AsyncArray, CompressorLike
9+
from zarr.core.array import DEFAULT_FILL_VALUE, Array, AsyncArray, CompressorLike, FilterLike
1010
from zarr.core.group import Group
1111
from zarr.core.sync import sync
1212
from zarr.core.sync_group import create_hierarchy
1313

1414
if TYPE_CHECKING:
1515
from collections.abc import Iterable
1616

17-
import numcodecs.abc
1817
import numpy as np
1918
import numpy.typing as npt
2019

2120
from zarr.abc.codec import Codec
2221
from zarr.api.asynchronous import ArrayLike, PathLike
2322
from zarr.core.array import (
24-
CompressorsLike,
25-
FiltersLike,
23+
CompressorLike,
2624
SerializerLike,
2725
ShardsLike,
2826
)
@@ -601,15 +599,15 @@ def create(
601599
*, # Note: this is a change from v2
602600
chunks: ChunkCoords | int | bool | None = None,
603601
dtype: ZDTypeLike | None = None,
604-
compressor: CompressorLike = "auto",
602+
compressor: CompressorLike | None | Literal["auto"] = "auto",
605603
fill_value: Any | None = DEFAULT_FILL_VALUE, # TODO: need type
606604
order: MemoryOrder | None = None,
607605
store: str | StoreLike | None = None,
608606
synchronizer: Any | None = None,
609607
overwrite: bool = False,
610608
path: PathLike | None = None,
611609
chunk_store: StoreLike | None = None,
612-
filters: Iterable[dict[str, JSON] | numcodecs.abc.Codec] | None = None,
610+
filters: Iterable[FilterLike] | None = None,
613611
cache_metadata: bool | None = None,
614612
cache_attrs: bool | None = None,
615613
read_only: bool | None = None,
@@ -756,9 +754,9 @@ def create_array(
756754
data: np.ndarray[Any, np.dtype[Any]] | None = None,
757755
chunks: ChunkCoords | Literal["auto"] = "auto",
758756
shards: ShardsLike | None = None,
759-
filters: FiltersLike = "auto",
760-
compressors: CompressorsLike = "auto",
761-
serializer: SerializerLike = "auto",
757+
filters: Iterable[FilterLike] | None | Literal["auto"] = "auto",
758+
compressors: CompressorLike | Iterable[CompressorLike] | None | Literal["auto"] = "auto",
759+
serializer: SerializerLike | Literal["auto"] = "auto",
762760
fill_value: Any | None = DEFAULT_FILL_VALUE,
763761
order: MemoryOrder | None = None,
764762
zarr_format: ZarrFormat | None = 3,
@@ -922,8 +920,8 @@ def from_array(
922920
name: str | None = None,
923921
chunks: Literal["auto", "keep"] | ChunkCoords = "keep",
924922
shards: ShardsLike | None | Literal["keep"] = "keep",
925-
filters: FiltersLike | Literal["keep"] = "keep",
926-
compressors: CompressorsLike | Literal["keep"] = "keep",
923+
filters: Iterable[FilterLike] | Literal["keep"] = "keep",
924+
compressors: Iterable[CompressorLike] | Literal["keep"] = "keep",
927925
serializer: SerializerLike | Literal["keep"] = "keep",
928926
fill_value: Any | None = DEFAULT_FILL_VALUE,
929927
order: MemoryOrder | None = None,

0 commit comments

Comments
 (0)