Skip to content

Conversation

@AlexWaygood
Copy link
Member

Fixes #6575

Cc: @JukkaL

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

pandas (https://github.com/pandas-dev/pandas)
- pandas/core/indexes/base.py:3857: error: Argument 1 has incompatible type "Union[ExtensionArray, ndarray[Any, Any]]"; expected "Union[_SupportsLE, _SupportsGE, _SupportsGT, _SupportsLT]"  [arg-type]
+ pandas/core/indexes/base.py:3857: error: Argument 1 has incompatible type "Union[ExtensionArray, ndarray[Any, Any]]"; expected "Union[SupportsDunderLE, SupportsDunderGE, SupportsDunderGT, SupportsDunderLT]"  [arg-type]
- pandas/core/indexes/base.py:3857: error: Argument 2 has incompatible type "Union[ExtensionArray, ndarray[Any, Any]]"; expected "Union[_SupportsLE, _SupportsGE, _SupportsGT, _SupportsLT]"  [arg-type]
+ pandas/core/indexes/base.py:3857: error: Argument 2 has incompatible type "Union[ExtensionArray, ndarray[Any, Any]]"; expected "Union[SupportsDunderLE, SupportsDunderGE, SupportsDunderGT, SupportsDunderLT]"  [arg-type]
- pandas/core/arrays/sparse/array.py:1552: error: Cannot call function of unknown type  [operator]
- pandas/io/formats/style.py:3502: error: Argument 2 to "ge" has incompatible type "Union[str, Any, float, Period, Timestamp, Timedelta, Sequence[Any], ndarray[Any, Any], NDFrame]"; expected "Union[_SupportsLE, _SupportsGE, _SupportsGT, _SupportsLT]"  [arg-type]
+ pandas/io/formats/style.py:3502: error: Argument 2 to "ge" has incompatible type "Union[str, Any, float, Period, Timestamp, Timedelta, Sequence[Any], ndarray[Any, Any], NDFrame]"; expected "Union[SupportsDunderLE, SupportsDunderGE, SupportsDunderGT, SupportsDunderLT]"  [arg-type]
- pandas/io/formats/style.py:3507: error: Argument 2 to "le" has incompatible type "Union[str, Any, float, Period, Timestamp, Timedelta, Sequence[Any], ndarray[Any, Any], NDFrame]"; expected "Union[_SupportsLE, _SupportsGE, _SupportsGT, _SupportsLT]"  [arg-type]
+ pandas/io/formats/style.py:3507: error: Argument 2 to "le" has incompatible type "Union[str, Any, float, Period, Timestamp, Timedelta, Sequence[Any], ndarray[Any, Any], NDFrame]"; expected "Union[SupportsDunderLE, SupportsDunderGE, SupportsDunderGT, SupportsDunderLT]"  [arg-type]

paasta (https://github.com/yelp/paasta)
- paasta_tools/metrics/metastatus_lib.py:650: error: Argument "key" to "sorted" has incompatible type "Callable[[Any], Sequence[Tuple[str, str]]]"; expected "Callable[[_SlaveT], SupportsLessThan]"
+ paasta_tools/metrics/metastatus_lib.py:650: error: Argument "key" to "sorted" has incompatible type "Callable[[Any], Sequence[Tuple[str, str]]]"; expected "Callable[[_SlaveT], Union[SupportsDunderLT, SupportsDunderGT]]"
- paasta_tools/metrics/metastatus_lib.py:650: error: Argument "key" to "sorted" has incompatible type "Callable[[Any], Sequence[Tuple[str, str]]]"; expected "Callable[[Any], SupportsLessThan]"
+ paasta_tools/metrics/metastatus_lib.py:650: error: Argument "key" to "sorted" has incompatible type "Callable[[Any], Sequence[Tuple[str, str]]]"; expected "Callable[[Any], Union[SupportsDunderLT, SupportsDunderGT]]"

streamlit (https://github.com/streamlit/streamlit)
- lib/tests/streamlit/watcher/local_sources_watcher_test.py:294:47: error: Returning Any from function declared to return "SupportsLessThan"  [no-any-return]
+ lib/tests/streamlit/watcher/local_sources_watcher_test.py:294:47: error: Returning Any from function declared to return "Union[SupportsDunderLT, SupportsDunderGT]"  [no-any-return]

Copy link
Contributor

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Nice, these types seem to reflect the runtime behavior more precisely!

@JukkaL JukkaL merged commit 5670ca2 into python:master Dec 14, 2021
@AlexWaygood AlexWaygood deleted the rich-comparisons branch December 14, 2021 14:17
AlexWaygood added a commit to AlexWaygood/mypy that referenced this pull request Mar 15, 2022
`SupportsLessThan` was removed from `_typeshed` in python/typeshed#6583 and replaced with a new `SupportsRichComparison` type, which better reflects the types at runtime.

Fixes python#12355
97littleleaf11 pushed a commit to python/mypy that referenced this pull request Mar 15, 2022
`SupportsLessThan` was removed from `_typeshed` in 
python/typeshed#6583 and replaced with 
a new `SupportsRichComparison` type, which better reflects the 
types at runtime.

Fixes #12355
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

max() works with greater-than or less-than

2 participants