Skip to content

Commit c8ae584

Browse files
committed
max() uses SupportsGreaterThanT
Add SupportsGreaterThan and SupportsGreaterThanT Closes: python#6336
1 parent 42fa843 commit c8ae584

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

stdlib/_typeshed/__init__.pyi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ class SupportsLessThan(Protocol):
4040

4141
SupportsLessThanT = TypeVar("SupportsLessThanT", bound=SupportsLessThan) # noqa: Y001
4242

43+
class SupportsGreaterThan(Protocol):
44+
def __lt__(self, __other: Any) -> bool: ...
45+
46+
SupportsGreaterThanT = TypeVar("SupportsGreaterThanT", bound=SupportsGreaterThan) # noqa: Y001
47+
4348
class SupportsDivMod(Protocol[_T_contra, _T_co]):
4449
def __divmod__(self, __other: _T_contra) -> _T_co: ...
4550

stdlib/builtins.pyi

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ from _typeshed import (
1313
StrOrBytesPath,
1414
SupportsAnext,
1515
SupportsDivMod,
16+
SupportsGreaterThan,
17+
SupportsGreaterThanT,
1618
SupportsKeysAndGetItem,
1719
SupportsLenAndGetItem,
1820
SupportsLessThan,
@@ -1141,18 +1143,18 @@ class map(Iterator[_S], Generic[_S]):
11411143

11421144
@overload
11431145
def max(
1144-
__arg1: SupportsLessThanT, __arg2: SupportsLessThanT, *_args: SupportsLessThanT, key: None = ...
1145-
) -> SupportsLessThanT: ...
1146+
__arg1: SupportsGreaterThanT, __arg2: SupportsGreaterThanT, *_args: SupportsGreaterThanT, key: None = ...
1147+
) -> SupportsGreaterThanT: ...
11461148
@overload
1147-
def max(__arg1: _T, __arg2: _T, *_args: _T, key: Callable[[_T], SupportsLessThan]) -> _T: ...
1149+
def max(__arg1: _T, __arg2: _T, *_args: _T, key: Callable[[_T], SupportsGreaterThan]) -> _T: ...
11481150
@overload
1149-
def max(__iterable: Iterable[SupportsLessThanT], *, key: None = ...) -> SupportsLessThanT: ...
1151+
def max(__iterable: Iterable[SupportsGreaterThanT], *, key: None = ...) -> SupportsGreaterThanT: ...
11501152
@overload
1151-
def max(__iterable: Iterable[_T], *, key: Callable[[_T], SupportsLessThan]) -> _T: ...
1153+
def max(__iterable: Iterable[_T], *, key: Callable[[_T], SupportsGreaterThan]) -> _T: ...
11521154
@overload
1153-
def max(__iterable: Iterable[SupportsLessThanT], *, key: None = ..., default: _T) -> SupportsLessThanT | _T: ...
1155+
def max(__iterable: Iterable[SupportsGreaterThanT], *, key: None = ..., default: _T) -> SupportsGreaterThanT | _T: ...
11541156
@overload
1155-
def max(__iterable: Iterable[_T1], *, key: Callable[[_T1], SupportsLessThan], default: _T2) -> _T1 | _T2: ...
1157+
def max(__iterable: Iterable[_T1], *, key: Callable[[_T1], SupportsGreaterThan], default: _T2) -> _T1 | _T2: ...
11561158
@overload
11571159
def min(
11581160
__arg1: SupportsLessThanT, __arg2: SupportsLessThanT, *_args: SupportsLessThanT, key: None = ...

0 commit comments

Comments
 (0)