From 1636969645dec1887ca0fd7aeeeda1c6881a2bf1 Mon Sep 17 00:00:00 2001 From: Davis Vann Bennett Date: Wed, 9 Sep 2026 15:21:14 +0200 Subject: [PATCH] chore(metadata): import Literal at module level in v2.py parse_zarr_format needs Literal at runtime for its parse_field type argument, so #4063 added a function-local import next to the existing TYPE_CHECKING one. Import it once at module level like the other modules that commit touched. The docstring and depth-limit corrections this branch originally carried are superseded by #4330, which removes the attribute depth limit and the validate_json_value helper entirely. Assisted-by: ClaudeCode:claude-fable-5-1 --- src/zarr/core/metadata/v2.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/zarr/core/metadata/v2.py b/src/zarr/core/metadata/v2.py index 70d4e1e59c..5822a228b9 100644 --- a/src/zarr/core/metadata/v2.py +++ b/src/zarr/core/metadata/v2.py @@ -4,7 +4,7 @@ import warnings from collections.abc import Iterable, Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, TypedDict, cast +from typing import TYPE_CHECKING, Any, Literal, TypedDict, cast from zarr.abc.metadata import Metadata from zarr.abc.numcodec import Numcodec, _is_numcodec @@ -14,7 +14,7 @@ from zarr.registry import get_numcodec if TYPE_CHECKING: - from typing import Literal, Self + from typing import Self import numpy.typing as npt @@ -279,8 +279,6 @@ def parse_dtype(data: npt.DTypeLike) -> np.dtype[Any]: def parse_zarr_format(data: object) -> Literal[2]: - from typing import Literal - return cast("Literal[2]", parse_field(data, Literal[2], "zarr_format"))