Skip to content

Conversation

charris
Copy link
Member

@charris charris commented Jan 6, 2025

Backport of #28108 and #28089.

This improved the return types of the following numpy.ndarray methods:

  • __[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 slice types.

The updated bundled typeshed was causing memoryview[int] to not be accepted anymore by npt.ArrayLike on python<3.12. This was also the case with pyright. I solved this by backporting collections.abc.Buffer on python<3.12, and included it in the numpy.typing.ArrayLike type alias, making it equivalent to its python>=3.12 variant (from a static typing perspective).

1.14.1 release notes

@charris charris added 08 - Backport Used to tag backport PRs 41 - Static typing labels Jan 6, 2025
@charris charris added this to the 2.2.2 release milestone Jan 6, 2025
@charris charris closed this Jan 7, 2025
@charris charris reopened this Jan 7, 2025
* 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`
@charris charris merged commit 7d9dcd6 into numpy:maintenance/2.2.x Jan 7, 2025
64 of 67 checks passed
@charris charris deleted the backport-28108 branch January 7, 2025 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
08 - Backport Used to tag backport PRs 41 - Static typing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants