Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2025

Conversation

charris
Copy link
Member

@charris charris commented Apr 4, 2025

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 charris added 08 - Backport Used to tag backport PRs 41 - Static typing labels Apr 4, 2025
@charris charris added this to the 2.2.5 release milestone Apr 4, 2025
@charris charris merged commit bac7b36 into numpy:maintenance/2.2.x Apr 4, 2025
70 checks passed
@charris charris deleted the backport-28644 branch April 4, 2025 20:58
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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.