From 0edb87fc6b426bd9eb31a579ace90d44c77b2ade Mon Sep 17 00:00:00 2001 From: Jakub Stasiak Date: Wed, 10 Aug 2016 21:12:52 +0200 Subject: [PATCH] Make functools.cmp_to_key more realistic (#458) The documentation[1] says: A comparison function is any callable that accept two arguments, compares them, and returns a negative number for less-than, zero for equality, or a positive number for greater-than. This doesn't seem possible with the comparison function defined as returning bool. [1] https://docs.python.org/3.6/library/functools.html#functools.cmp_to_key --- stdlib/2.7/functools.pyi | 2 +- stdlib/3/functools.pyi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/2.7/functools.pyi b/stdlib/2.7/functools.pyi index c1637643e..884076578 100644 --- a/stdlib/2.7/functools.pyi +++ b/stdlib/2.7/functools.pyi @@ -24,7 +24,7 @@ def update_wrapper(wrapper: _AnyCallable, wrapped: _AnyCallable, assigned: Seque updated: Sequence[str] = ...) -> None: ... def wraps(wrapped: _AnyCallable, assigned: Sequence[str] = ..., updated: Sequence[str] = ...) -> Callable[[_AnyCallable], _AnyCallable]: ... def total_ordering(cls: type) -> type: ... -def cmp_to_key(mycmp: Callable[[_T, _T], bool]) -> Callable[[_T], Any]: ... +def cmp_to_key(mycmp: Callable[[_T, _T], int]) -> Callable[[_T], Any]: ... class partial(Generic[_T]): func = ... # Callable[..., _T] diff --git a/stdlib/3/functools.pyi b/stdlib/3/functools.pyi index 0982cfebd..2bd79ef71 100644 --- a/stdlib/3/functools.pyi +++ b/stdlib/3/functools.pyi @@ -40,7 +40,7 @@ def update_wrapper(wrapper: _AnyCallable, wrapped: _AnyCallable, assigned: Seque updated: Sequence[str] = ...) -> None: ... def wraps(wrapped: _AnyCallable, assigned: Sequence[str] = ..., updated: Sequence[str] = ...) -> Callable[[_AnyCallable], _AnyCallable]: ... def total_ordering(cls: type) -> type: ... -def cmp_to_key(mycmp: Callable[[_T, _T], bool]) -> Callable[[_T], Any]: ... +def cmp_to_key(mycmp: Callable[[_T, _T], int]) -> Callable[[_T], Any]: ... class partial(Generic[_T]): func = ... # Callable[..., _T]