Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/zarr/abc/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

@dataclass(frozen=True)
class Metadata:
def to_dict(self) -> JSON:
def to_dict(self) -> dict[str, JSON]:
"""
Recursively serialize this model to a dictionary.
This method inspects the fields of self and calls `x.to_dict()` for any fields that
Expand Down
4 changes: 2 additions & 2 deletions src/zarr/codecs/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class BatchedCodecPipeline(CodecPipeline):
batch_size: int

@classmethod
def from_dict(cls, data: Iterable[JSON | Codec], *, batch_size: int | None = None) -> Self:
def from_dict(cls, data: dict[str, JSON | Codec], *, batch_size: int | None = None) -> Self:
out: list[Codec] = []
if not isinstance(data, Iterable):
raise TypeError(f"Expected iterable, got {type(data)}")
Expand All @@ -84,7 +84,7 @@ def from_dict(cls, data: Iterable[JSON | Codec], *, batch_size: int | None = Non
out.append(get_codec_class(name_parsed).from_dict(c)) # type: ignore[arg-type]
return cls.from_list(out, batch_size=batch_size)

def to_dict(self) -> JSON:
def to_dict(self) -> dict[str, JSON]:
return [c.to_dict() for c in self]

def evolve_from_array_spec(self, array_spec: ArraySpec) -> Self:
Expand Down
2 changes: 1 addition & 1 deletion src/zarr/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def parse_name(data: JSON, expected: str | None = None) -> str:
raise TypeError(f"Expected a string, got an instance of {type(data)}.")


def parse_configuration(data: JSON) -> JSON:
def parse_configuration(data: JSON) -> dict[str, JSON]:
if not isinstance(data, dict):
raise TypeError(f"Expected dict, got {type(data)}")
return data
Expand Down
2 changes: 1 addition & 1 deletion src/zarr/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def from_dict(cls, data: dict[str, Any]) -> ArrayV2Metadata:
_ = parse_zarr_format_v2(data.pop("zarr_format"))
return cls(**data)

def to_dict(self) -> JSON:
def to_dict(self) -> dict[str, JSON]:
zarray_dict = super().to_dict()

assert isinstance(zarray_dict, dict)
Expand Down