Skip to content

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!

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