Skip to content

TYP: Fix false rejection of NDArray[object_].__abs__() #28705

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 14, 2025

Conversation

charris
Copy link
Member

@charris charris commented Apr 14, 2025

Backport of #28699.

partial port of numpy/numtype#508


Static type-checkers currently reject abs(np.array([1], np.object_)), even though it is a valid runtime expression. This adds an __abs__ method to np.object_, indirectly causing type-checkers to accept calls to NDArray[object_].__abs__ as well.

@charris charris added 08 - Backport Used to tag backport PRs 41 - Static typing numtype Isssue/PR related to numpy/numtype labels Apr 14, 2025
@charris charris added this to the 2.2.5 release milestone Apr 14, 2025
@charris charris merged commit 202732d into numpy:maintenance/2.2.x Apr 14, 2025
70 checks passed
@charris charris deleted the backport-28699 branch April 14, 2025 17:20
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 numtype Isssue/PR related to numpy/numtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants