Skip to content

Commit 8ad3aed

Browse files
authored
Merge branch 'main' into optional-deps
2 parents f86e746 + 4e53a70 commit 8ad3aed

File tree

13 files changed

+24
-25
lines changed

13 files changed

+24
-25
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
ci:
22
autoupdate_commit_msg: "chore: update pre-commit hooks"
3+
autoupdate_schedule: "monthly"
34
autofix_commit_msg: "style: pre-commit fixes"
45
autofix_prs: false
56
default_stages: [pre-commit, pre-push]
6-
default_language_version:
7-
python: python3
87
repos:
98
- repo: https://github.com/astral-sh/ruff-pre-commit
10-
rev: v0.8.1
9+
rev: v0.8.2
1110
hooks:
1211
- id: ruff
1312
args: ["--fix", "--show-fixes"]
@@ -16,7 +15,7 @@ repos:
1615
rev: v2.3.0
1716
hooks:
1817
- id: codespell
19-
args: ["-L", "ba,ihs,kake,nd,noe,nwo,te,fo,zar", "-S", "fixture"]
18+
args: ["-L", "fo,ihs,kake,te", "-S", "fixture"]
2019
- repo: https://github.com/pre-commit/pre-commit-hooks
2120
rev: v5.0.0
2221
hooks:

src/zarr/core/array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ async def _create_v2(
604604
dtype: npt.DTypeLike,
605605
chunks: ChunkCoords,
606606
dimension_separator: Literal[".", "/"] | None = None,
607-
fill_value: None | float = None,
607+
fill_value: float | None = None,
608608
order: MemoryOrder | None = None,
609609
filters: list[dict[str, JSON]] | None = None,
610610
compressor: dict[str, JSON] | None = None,

src/zarr/core/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
ChunkCoordsLike = Iterable[int]
3737
ZarrFormat = Literal[2, 3]
3838
NodeType = Literal["array", "group"]
39-
JSON = None | str | int | float | Mapping[str, "JSON"] | tuple["JSON", ...]
39+
JSON = str | int | float | Mapping[str, "JSON"] | tuple["JSON", ...] | None
4040
MemoryOrder = Literal["C", "F"]
4141
AccessModeLiteral = Literal["r", "r+", "a", "w", "w-"]
4242

src/zarr/core/metadata/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from zarr.core.common import JSON
77

88

9-
def parse_attributes(data: None | dict[str, JSON]) -> dict[str, JSON]:
9+
def parse_attributes(data: dict[str, JSON] | None) -> dict[str, JSON]:
1010
if data is None:
1111
return {}
1212

src/zarr/core/metadata/v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ArrayV2Metadata(Metadata):
4444
shape: ChunkCoords
4545
chunks: tuple[int, ...]
4646
dtype: np.dtype[Any]
47-
fill_value: None | int | float | str | bytes = 0
47+
fill_value: int | float | str | bytes | None = 0
4848
order: MemoryOrder = "C"
4949
filters: tuple[numcodecs.abc.Codec, ...] | None = None
5050
dimension_separator: Literal[".", "/"] = "."

src/zarr/core/metadata/v3.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,9 @@ def __init__(
225225
chunk_key_encoding: dict[str, JSON] | ChunkKeyEncoding,
226226
fill_value: Any,
227227
codecs: Iterable[Codec | dict[str, JSON]],
228-
attributes: None | dict[str, JSON],
229-
dimension_names: None | Iterable[str],
230-
storage_transformers: None | Iterable[dict[str, JSON]] = None,
228+
attributes: dict[str, JSON] | None,
229+
dimension_names: Iterable[str] | None,
230+
storage_transformers: Iterable[dict[str, JSON]] | None = None,
231231
) -> None:
232232
"""
233233
Because the class is a frozen dataclass, we set attributes using object.__setattr__
@@ -540,7 +540,7 @@ class DataType(Enum):
540540
bytes = "bytes"
541541

542542
@property
543-
def byte_count(self) -> None | int:
543+
def byte_count(self) -> int | None:
544544
data_type_byte_counts = {
545545
DataType.bool: 1,
546546
DataType.int8: 1,
@@ -626,7 +626,7 @@ def from_numpy(cls, dtype: np.dtype[Any]) -> DataType:
626626
return DataType[dtype_to_data_type[dtype.str]]
627627

628628
@classmethod
629-
def parse(cls, dtype: None | DataType | Any) -> DataType:
629+
def parse(cls, dtype: DataType | Any | None) -> DataType:
630630
if dtype is None:
631631
return DataType[DEFAULT_DTYPE]
632632
if isinstance(dtype, DataType):

src/zarr/storage/_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def normalize_path(path: str | bytes | Path | None) -> str:
4545

4646

4747
def _normalize_interval_index(
48-
data: Buffer, interval: None | tuple[int | None, int | None]
48+
data: Buffer, interval: tuple[int | None, int | None] | None
4949
) -> tuple[int, int]:
5050
"""
5151
Convert an implicit interval into an explicit start and length

src/zarr/testing/store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def test_store_supports_listing(self, store: S) -> None:
106106
@pytest.mark.parametrize("data", [b"\x01\x02\x03\x04", b""])
107107
@pytest.mark.parametrize("byte_range", [None, (0, None), (1, None), (1, 2), (None, 1)])
108108
async def test_get(
109-
self, store: S, key: str, data: bytes, byte_range: None | tuple[int | None, int | None]
109+
self, store: S, key: str, data: bytes, byte_range: tuple[int | None, int | None] | None
110110
) -> None:
111111
"""
112112
Ensure that data can be read from the store using the store.get method.

src/zarr/testing/strategies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def arrays(
117117
shapes: st.SearchStrategy[tuple[int, ...]] = array_shapes,
118118
compressors: st.SearchStrategy = compressors,
119119
stores: st.SearchStrategy[StoreLike] = stores,
120-
paths: st.SearchStrategy[None | str] = paths,
120+
paths: st.SearchStrategy[str | None] = paths,
121121
array_names: st.SearchStrategy = array_names,
122122
arrays: st.SearchStrategy | None = None,
123123
attrs: st.SearchStrategy = attrs,

tests/test_codecs/test_vlen.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
@pytest.mark.parametrize("as_object_array", [False, True])
2626
@pytest.mark.parametrize("codecs", [None, [VLenUTF8Codec()], [VLenUTF8Codec(), ZstdCodec()]])
2727
def test_vlen_string(
28-
store: Store, dtype: None | np.dtype[Any], as_object_array: bool, codecs: None | list[Codec]
28+
store: Store, dtype: np.dtype[Any] | None, as_object_array: bool, codecs: list[Codec] | None
2929
) -> None:
3030
strings = ["hello", "world", "this", "is", "a", "test"]
3131
data = np.array(strings, dtype=dtype).reshape((2, 3))
@@ -62,7 +62,7 @@ def test_vlen_string(
6262
@pytest.mark.parametrize("store", ["memory", "local"], indirect=["store"])
6363
@pytest.mark.parametrize("as_object_array", [False, True])
6464
@pytest.mark.parametrize("codecs", [None, [VLenBytesCodec()], [VLenBytesCodec(), ZstdCodec()]])
65-
def test_vlen_bytes(store: Store, as_object_array: bool, codecs: None | list[Codec]) -> None:
65+
def test_vlen_bytes(store: Store, as_object_array: bool, codecs: list[Codec] | None) -> None:
6666
bstrings = [b"hello", b"world", b"this", b"is", b"a", b"test"]
6767
data = np.array(bstrings).reshape((2, 3))
6868
assert data.dtype == "|S5"

0 commit comments

Comments
 (0)