Skip to content

Support initial keyword for functools.reduce 3.14 #13995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion stdlib/@tests/stubtest_allowlists/py314.txt
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,6 @@ functools.__all__
functools.Placeholder
functools.WRAPPER_ASSIGNMENTS
functools.partialmethod.__new__
functools.reduce
functools.update_wrapper
functools.wraps
gzip.GzipFile.readinto
Expand Down
10 changes: 8 additions & 2 deletions stdlib/functools.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@ _RWrapped = TypeVar("_RWrapped")
_PWrapper = ParamSpec("_PWrapper")
_RWrapper = TypeVar("_RWrapper")

@overload
def reduce(function: Callable[[_T, _S], _T], sequence: Iterable[_S], initial: _T, /) -> _T: ...
if sys.version_info >= (3, 14):
@overload
def reduce(function: Callable[[_T, _S], _T], sequence: Iterable[_S], /, initial: _T) -> _T: ...

else:
@overload
def reduce(function: Callable[[_T, _S], _T], sequence: Iterable[_S], initial: _T, /) -> _T: ...

@overload
def reduce(function: Callable[[_T, _T], _T], sequence: Iterable[_T], /) -> _T: ...

Expand Down
Loading