Skip to content

Commit 23b2ae7

Browse files
committed
model the not-required-ness of the separator
1 parent 47d4b4e commit 23b2ae7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/zarr/core/chunk_key_encodings.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
from abc import abstractmethod
44
from dataclasses import dataclass
5-
from typing import Literal, TypeAlias, TypedDict, cast
5+
from typing import TYPE_CHECKING, Literal, TypeAlias, TypedDict, cast
6+
7+
if TYPE_CHECKING:
8+
from typing import NotRequired
69

710
from zarr.abc.metadata import Metadata
811
from zarr.core.common import (
@@ -22,7 +25,7 @@ def parse_separator(data: JSON) -> SeparatorLiteral:
2225

2326
class ChunkKeyEncodingParams(TypedDict):
2427
name: Literal["v2", "default"]
25-
separator: SeparatorLiteral
28+
separator: NotRequired[SeparatorLiteral]
2629

2730

2831
@dataclass(frozen=True)
@@ -45,7 +48,8 @@ def from_dict(cls, data: dict[str, JSON] | ChunkKeyEncodingLike) -> ChunkKeyEnco
4548
data = {"name": data["name"], "configuration": {"separator": data["separator"]}}
4649

4750
# configuration is optional for chunk key encodings
48-
name_parsed, config_parsed = parse_named_configuration(data, require_configuration=False)
51+
# TODO: remove the type: ignore statement when we use typeddicts for all our static metadata
52+
name_parsed, config_parsed = parse_named_configuration(data, require_configuration=False) # type: ignore[arg-type]
4953
if name_parsed == "default":
5054
if config_parsed is None:
5155
# for default, normalize missing configuration to use the "/" separator.

0 commit comments

Comments
 (0)