fix(zarr-indexing): replace runtime assert statements with explicit checks - #4364
Merged
d-v-b merged 1 commit intoSep 16, 2026
Merged
Conversation
…hecks Asserts are stripped under `python -O`. The sixteen in zarr-indexing's runtime code narrowed types or guarded internal invariants rather than validating input, so most are restructured away: `inverse` validates and builds in one pass, the correlated-block mask starts all-true instead of `None`, the lowering paths branch on the map type instead of on membership in a dims list, the vindex path keeps its slices in a typed dict, and the affine writer returns early on an index array. The remainder become `RuntimeError`s for states the public API cannot reach, via a `_finite` helper in the message layer and an explicit check in `_indexed_set`. The `packages/zarr-indexing/src/**` exemption from ruff's S101 rule is removed so the package is held to the same standard as `src/zarr`. Assisted-by: ClaudeCode:claude-fable-5-1
d-v-b
force-pushed
the
claude/nostalgic-feynman-1c2cfa
branch
from
September 16, 2026 11:41
37ff3c9 to
0172612
Compare
Documentation build overview
|
d-v-b
marked this pull request as ready for review
September 16, 2026 11:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AI-authored PR that cleans out runtime asserts from zarr-indexing.
🤖 AI text below 🤖
Follow-up to #4363, which enabled ruff's
S101(noassertin runtime code) repo-wide but left a temporary exemption forpackages/zarr-indexing/src/**. This removes the sixteen asserts that exemption covered and drops the exemption.Same treatment as #4363:
IndexTransform.inversevalidates and builds in one loop, so theArrayMaprejection narrows the map type directly. The correlated-block mask in_intersect_generalstarts as an all-true array instead ofNone. The general and orthogonal lowering paths inreader.pybranch onisinstancerather than on membership in a dims list and carry theArrayMaps in a paired list._apply_vindexkeeps its slices in a typed dict._write_affinemoves theArrayMapcheck into the loop as an earlyreturn False._resolve_upper_boundtests the raw list instead of the field name.RuntimeError(3 sites)._indexed_setraises if an orthogonal map has no dependent axis, whichindex_array_structureroutes to the general path before it can get there. A_finitehelper inmessages.pyreplaces the three post-validationisinstance(value, int)asserts.None of the new raises is reachable through the public API, so no new tests; the existing suite exercises every restructured path.
zarr_indexing/testing/is untouched (covered by the**/testing/**ignore).Verified:
ruff check .,ruff check packages/zarr-indexing/src --select S101 --ignore-noqa, rootmypy, the package'spyrightrecipe (no new warnings), and the zarr-indexing suite (1739 passed).🤖 Generated with Claude Code