TYP: Better ndarray binop return types for float64 & ``complex128"#28112
Merged
charris merged 2 commits intonumpy:maintenance/2.2.xfrom Jan 7, 2025
Merged
TYP: Better ndarray binop return types for float64 & ``complex128"#28112charris merged 2 commits intonumpy:maintenance/2.2.xfrom
ndarray binop return types for float64 & ``complex128"#28112charris merged 2 commits intonumpy:maintenance/2.2.xfrom
Conversation
* MAINT: bump `mypy` to `1.14.1` * TYP: fix new `mypy==1.14.1` type-test errors * TYP: backport `collections.abc.Buffer` for `npt.ArrayLike` on `python<3.11`
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.
Backport of #28108 and #28089.
This improved the return types of the following
numpy.ndarraymethods:__[r]add____[r]sub____[r]mul____[r]matmul____[r]truediv____[r]floordiv____[r]mod____[r]divmod____[r]pow__Closes #20099 (not sure why, but a win is a win 🤷🏻)
Closes #22631
Closes #27957
Closes #27965
Closes #28071
Towards #28076 (I'm guessing that this fixes something between 75%~95% of the possible 2.2.0 typing issues)
MAINT: bump mypy to 1.14.1
Some type-tests needed to be refined because mypy now supports generic
slicetypes.The updated bundled typeshed was causing
memoryview[int]to not be accepted anymore bynpt.ArrayLikeonpython<3.12. This was also the case with pyright. I solved this by backportingcollections.abc.Bufferonpython<3.12, and included it in thenumpy.typing.ArrayLiketype alias, making it equivalent to itspython>=3.12variant (from a static typing perspective).1.14.1release notes