Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1477,16 +1477,23 @@ def sorted(
) -> list[SupportsRichComparisonT]: ...
@overload
def sorted(__iterable: Iterable[_T], *, key: Callable[[_T], SupportsRichComparison], reverse: bool = ...) -> list[_T]: ...

class _SupportsSum(Protocol):
def __add__(self, __x: Any) -> Any: ...

_SumT = TypeVar("_SumT", bound=_SupportsSum)
_SumS = TypeVar("_SumS", bound=_SupportsSum)

@overload
def sum(__iterable: Iterable[_T]) -> _T | Literal[0]: ...
def sum(__iterable: Iterable[_SumT]) -> _SumT | Literal[0]: ...

if sys.version_info >= (3, 8):
@overload
def sum(__iterable: Iterable[_T], start: _S) -> _T | _S: ...
def sum(__iterable: Iterable[_SumT], start: _SumS) -> _SumT | _SumS: ...

else:
@overload
def sum(__iterable: Iterable[_T], __start: _S) -> _T | _S: ...
def sum(__iterable: Iterable[_SumT], __start: _SumS) -> _SumT | _SumS: ...

# The argument to `vars()` has to have a `__dict__` attribute, so can't be annotated with `object`
# (A "SupportsDunderDict" protocol doesn't work)
Expand Down