FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

TYP: fix `ndarray.tolist()` and `.item()` for unknown dtype by charris · Pull Request #28650 · numpy/numpy · GitHub

/ numpy Public

TYP: fix ndarray.tolist() and .item() for unknown dtype - #28650

Merged
charris merged 1 commit into
numpy:maintenance/2.2.xfrom
charris:backport-28644
Apr 4, 2025
Merged

charris merged 1 commit into
numpy:maintenance/2.2.xfrom
charris:backport-28644

Conversation

charris commented Apr 4, 2025

Copy link
Copy Markdown
Member

Backport of #28644.

This fixes #27944 for both mypy and pyright.

I used the new generic generic type as a more direct alternative to match the .item() type of the underlying scalar-type. This way, we don't have to rely on on pyright's constraint set solving algorithm (recently introduced so not yet in pylance, and slightly incorrect in case of overlap). Mypy doesn't support constraint-sets, and it instead always chooses the first matching overload, causing it to behave incorrectly.

charris added 08 - Backport Used to tag backport PRs 41 - Static typing labels Apr 4, 2025
charris added this to the 2.2.5 release milestone Apr 4, 2025
charris merged commit bac7b36 into numpy:maintenance/2.2.x Apr 4, 2025
charris deleted the backport-28644 branch April 4, 2025 20:58
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

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


Back | FazBrowse Home | New Git URL