Repository navigation
fix: type check with numpy 2.5.4 isscalar stubs - #1031
Open
MaykThewessen wants to merge 1 commit into
Open
MaykThewessen wants to merge 1 commit into
MaykThewessen wants to merge 1 commit into
Conversation
numpy 2.5.4 widened the TypeIs of np.isscalar to include numbers.Number, which xarray's DataArray.__add__ does not accept, so mypy fails on the legacy scalar branch of _add_constant. Cast to the scalar members of ConstantLike; no runtime change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merging this PR will not alter performance
Comparing Footnotes
|
MaykThewessen
added a commit
to MaykThewessen/linopy
that referenced
this pull request
Oct 12, 2026
MaykThewessen
added a commit
to MaykThewessen/linopy
that referenced
this pull request
Oct 12, 2026
MaykThewessen
added a commit
to MaykThewessen/linopy
that referenced
this pull request
Oct 12, 2026
MaykThewessen
added a commit
to MaykThewessen/linopy
that referenced
this pull request
Oct 12, 2026
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.
Note
AI-assisted. Claude found the cause and wrote the fix, and ran the checks listed below. I reviewed the diff.
Changes proposed in this Pull Request
"Check types" fails on every new CI run since numpy 2.5.4 (
linopy/expressions.py:1278: No overload variant of "__add__" ... matches argument type "Number"). numpy 2.5.4 addednumbers.Numberto theTypeIsofnp.isscalar, and xarray'sDataArray.__add__does not acceptNumber. This casts the scalar in the legacy_add_constantbranch tofloat | np.number, the scalar members ofConstantLike. No runtime change. This unblocks #1021, #1022, #1024 and #1025, among others.Checklist
AGENTS.md).doc.doc/release_notes.rstof the upcoming release is included.What was checked (AI-generated)
linopy/expressions.pytype-checks under numpy 2.5.3 and 2.5.4.test/test_linear_expression.pypasses.🤖 Generated with Claude Code