Repository navigation
Conversation
carljm
marked this pull request as draft
November 15, 2026 05:38
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
carljm
marked this pull request as ready for review
November 15, 2026 05:55
AlexWaygood
requested changes
Nov 15, 2026
carljm
force-pushed
the
cjm/operator-rich-comparisons
branch
from
November 15, 2026 16:35
9eab27d to
573a07c
Compare
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: pandera (https://github.com/pandera-dev/pandera)
+ pandera/backends/xarray/builtin_checks.py:404: error: Unused "type: ignore" comment [unused-ignore]
+ pandera/backends/pandas/builtin_checks.py:195: error: Unused "type: ignore" comment [unused-ignore]
pandas (https://github.com/pandas-dev/pandas)
+ pandas/io/formats/style.py:4410: error: Unused "type: ignore" comment [unused-ignore]
+ pandas/io/formats/style.py:4421: error: Unused "type: ignore" comment [unused-ignore]
|
AlexWaygood
approved these changes
Nov 15, 2026
Comment on lines
+25
to
+26
| # operator returns the rich comparison result without testing its truth value, so these protocols | ||
| # return `object` (unlike the similar protocols in `_typeshed`). |
Member
There was a problem hiding this comment.
Suggested change
| # operator returns the rich comparison result without testing its truth value, so these protocols | |
| # return `object` (unlike the similar protocols in `_typeshed`). | |
| # Unlike other stdlib APIs, APIs in the `operator` module return the result of calling a rich-comparison | |
| # method without testing the truth value of that result. Thus, whereas `_typeshed.SupportsDunderLT` | |
| # (a general-purpose API used in multiple locations) returns `SupportsBool`, it's sufficient for | |
| # the version here to return `object`. |
This branch has not been deployed
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since #16014,
operator.lt(x, y)can fail type checking even whenx < yis valid, whenx.__lt__(y)returns an object with no__bool__method. Python allowsx < yto return that object directly, andoperator.lt(x, y)has the same behavior.Also, the current stubs for
operator.lt,le,gt, andgerequire both operands to define an ordering method. Python only requires one operand to handle the comparison.Update
operator.lt,le,gt, andgeto accept ordering methods with arbitrary return types and allow heterogeneous operands where either side implements the comparison.Assisted by Codex.