diff --git a/stdlib/_operator.pyi b/stdlib/_operator.pyi index b337d84da4cb..a945a0be74a4 100644 --- a/stdlib/_operator.pyi +++ b/stdlib/_operator.pyi @@ -14,6 +14,7 @@ from typing import ( SupportsAbs, Tuple, TypeVar, + Union, overload, ) from typing_extensions import ParamSpec, SupportsIndex, final @@ -34,12 +35,27 @@ class _SupportsNeg(Protocol[_T_co]): class _SupportsPos(Protocol[_T_co]): def __pos__(self) -> _T_co: ... -def lt(__a: Any, __b: Any) -> Any: ... -def le(__a: Any, __b: Any) -> Any: ... +# Different to _typeshed.SupportsLessThan +class _SupportsLT(Protocol): + def __lt__(self, other: Any) -> Any: ... + +class _SupportsGT(Protocol): + def __gt__(self, other: Any) -> Any: ... + +class _SupportsLE(Protocol): + def __le__(self, other: Any) -> Any: ... + +class _SupportsGE(Protocol): + def __ge__(self, other: Any) -> Any: ... + +_SupportsComparison = Union[_SupportsLE, _SupportsGE, _SupportsGT, _SupportsLT] + +def lt(__a: _SupportsComparison, __b: _SupportsComparison) -> Any: ... +def le(__a: _SupportsComparison, __b: _SupportsComparison) -> Any: ... def eq(__a: object, __b: object) -> Any: ... def ne(__a: object, __b: object) -> Any: ... -def ge(__a: Any, __b: Any) -> Any: ... -def gt(__a: Any, __b: Any) -> Any: ... +def ge(__a: _SupportsComparison, __b: _SupportsComparison) -> Any: ... +def gt(__a: _SupportsComparison, __b: _SupportsComparison) -> Any: ... def not_(__a: object) -> bool: ... def truth(__a: object) -> bool: ... def is_(__a: object, __b: object) -> bool: ...