Thanks to visit codestin.com
Credit goes to github.com

Skip to content

TYP: Improved numpy.generic rich comparison operator type annotations. #26942

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
Jul 23, 2024

Conversation

jorenham
Copy link
Member

This affects numpy.generic subtypes that implement __lt__, __le__, __gt__, or (but usually "and") __ge__.

Note that there are no commutativity issues here, because the numpy implementations of these comparison ops always return a np.bool scalar or array, regardless of the return type of the respective reflected comparison op of the "other" operand.
And in the case that the generic subtype is on the right-hand side, type checkers will first consider the respective dunder method of the left-hand side.

@jorenham jorenham changed the title TYP: Improved numpy.generic rich comparison operator type annotations. TYP: Improved numpy.generic rich comparison operator type annotations. Jul 14, 2024
@jorenham jorenham force-pushed the improved-comparison-op-typing branch from 616fc58 to d58b26c Compare July 15, 2024 16:45
@jorenham
Copy link
Member Author

It looks like there are some flaky tests?

@jorenham jorenham force-pushed the improved-comparison-op-typing branch from d58b26c to 70a7a41 Compare July 22, 2024 03:36
@rgommers
Copy link
Member

It looks like there are some flaky tests?

Not uncommon - you can simply ignore them if they're clearly unrelated. A red CI isn't blocking for merge.

Copy link
Member

@rgommers rgommers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks @jorenham!

@rgommers rgommers merged commit 1148073 into numpy:main Jul 23, 2024
68 checks passed
@rgommers rgommers added this to the 2.1.0 release milestone Jul 23, 2024
@jorenham jorenham deleted the improved-comparison-op-typing branch July 23, 2024 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants