Skip to content

build(zarr-metadata): type-check the tests - #4421

Merged
d-v-b merged 2 commits into
zarr-developers:mainfrom
d-v-b:build/zarr-metadata-typecheck-tests
Sep 26, 2026
Merged

d-v-b merged 2 commits into
zarr-developers:mainfrom
d-v-b:build/zarr-metadata-typecheck-tests

Conversation

@d-v-b

@d-v-b d-v-b commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Pyright now checks tests as well as src. Test bodies are held to less inference strictness than the sources, since they are full of untyped JSON literals, but a dangling import, a call that no longer type-checks, or an argument of the wrong type is an error. # type: ignore is switched off, so a suppression is # pyright: ignore[rule]: it names its rule, and it fails once it stops suppressing anything. The tests' own type errors are fixed without casts.

Checking the tests found one real bug, fixed in the first commit with its changelog entry. to_key_value keys its result by the store-key literals, as the changelog documents, and a mapping's key type is invariant, so ZarrV3ArrayMetadata.from_key_value(model.to_key_value()) did not type-check. from_key_value is now generic in its key type, and still accepts any str-keyed store.

just check now runs the tests on the oldest and newest interpreters the package declares, both read from pyproject.toml. The pyright pin moves from 1.1.404 to 1.1.414: the old pin avoided a regression in how pyright types PEP 661 sentinels (microsoft/pyright#11115), which 1.1.413 fixed.

This is one of three independent PRs from one review: #4420 lets attributes hold NaN and the infinities, and #4422 adds runtime checks to ValidationProblem. Each is based on main and can merge in any order. #4420 has merged, and this is rebased onto it. #4421 and #4422 still change the same import line in model/_validation.py, so whichever merges second needs a one-line rebase.

🤖 Generated with Claude Code

@github-actions github-actions Bot added needs release notes Automatically applied to PRs which haven't added release notes zarr-metadata Specific to the zarr-metadata sub-package labels Sep 26, 2026
@d-v-b
d-v-b force-pushed the build/zarr-metadata-typecheck-tests branch from e0db629 to 71b8d11 Compare September 26, 2026 15:06
@read-the-docs-community

read-the-docs-community Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 zarr-metadata | 🛠️ Build #34777486 | 📁 Comparing e009bc3 against latest (f58644a)

  🔍 Preview build  

2 files changed
± api/model/index.html
± api/pydantic/index.html

`to_key_value` keys its result by the store-key literals, and a mapping's
key type is invariant, so passing that result to `from_key_value`, which
took `Mapping[str, bytes]`, did not type-check. `from_key_value` now takes
a mapping keyed by `str` or by any narrower key type.

Assisted-by: ClaudeCode:claude-opus-5-5
… version range

Pyright checks `tests` as well as `src`, relaxed only for the inferred
types of JSON literals, and `# type: ignore` is switched off: a
suppression names its rule. The tests' own type errors are fixed
without casts. `just check` runs the suite on the oldest and newest
interpreters the package declares, and pyright is pinned at 1.1.414.

Assisted-by: ClaudeCode:claude-opus-5-5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs release notes Automatically applied to PRs which haven't added release notes zarr-metadata Specific to the zarr-metadata sub-package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant