Repository navigation
Conversation
`save_array` rejects anything that is not `NDArrayLike` before it reaches `np.isscalar(arr)`. numpy scalars lack `__len__` and `__setitem__`, so they never pass the protocol check, and the `np.array(arr)` fallback was dead. numpy 2.5.4 changed the `np.isscalar` stub from `TypeGuard` to `TypeIs`, which lets mypy intersect the narrowed `NDArrayLike` with the scalar union and report the branch as unreachable. Delete it and pin the error path. Assisted-by: ClaudeCode:claude-fable-5-1
This branch has not been deployed
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 text below 🤖
save_arrayrejects anything that is notNDArrayLikebefore it reachesnp.isscalar(arr), and numpy scalars never pass that protocol check because they lack__len__and__setitem__, so thenp.array(arr)fallback could never run. This PR deletes the dead branch and adds a test pinning theTypeErrorpath that actually handles scalars.Why now
numpy 2.5.4 changed the
np.isscalarstub fromTypeGuard[...]toTypeIs[...]. ATypeIslets mypy intersect the already-narrowedNDArrayLikewith the scalar union, discover the intersection is empty, and reportStatement is unreachable. That is the lint failure on the upstream dependabot bump zarr-developers/zarr-python#4549, where mypy fails only because the lock moves numpy from 2.5.2 to 2.5.4. The agent bisected it: mypy 2.4.0 with numpy 2.5.2 passes, mypy 2.3.1 with numpy 2.5.4 fails.Verification
uv run --frozen mypypasses on all 203 files under both numpy 2.5.2 (this branch's lock) and 2.5.4 (the dependabot lock).save-related tests intests/test_api.pypass, plus the newtest_save_array_rejects_scalar.No changelog fragment: internal cleanup with no user-visible behavior change.
Stack bookkeeping
Independent of other PRs. Once this lands on upstream main, the dependabot PR 4549 needs a rebase for its lint job to go green.
🤖 Generated with Claude Code