From 9acc9b31ac9c4e824476cc8178436e9f3f8d117f Mon Sep 17 00:00:00 2001 From: Tomasz Elendt Date: Sun, 5 Jun 2016 01:00:45 +0200 Subject: [PATCH] Fix heapq.merge signature for Python >= 3.5 (#227) (#261) Add the optional key and reverse parameters: https://docs.python.org/3.5/library/heapq.html#heapq.merge --- stdlib/3/heapq.pyi | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/stdlib/3/heapq.pyi b/stdlib/3/heapq.pyi index 0894f983c..81b6135e8 100644 --- a/stdlib/3/heapq.pyi +++ b/stdlib/3/heapq.pyi @@ -2,6 +2,7 @@ # Based on http://docs.python.org/3.2/library/heapq.html +import sys from typing import TypeVar, List, Iterable, Any, Callable _T = TypeVar('_T') @@ -11,7 +12,11 @@ def heappop(heap: List[_T]) -> _T: ... def heappushpop(heap: List[_T], item: _T) -> _T: ... def heapify(x: List[_T]) -> None: ... def heapreplace(heap: List[_T], item: _T) -> _T: ... -def merge(*iterables: Iterable[_T]) -> Iterable[_T]: ... +if sys.version_info >= (3, 5): + def merge(*iterables: Iterable[_T], key: Callable[[_T], Any] = ..., + reverse: bool = ...) -> Iterable[_T]: ... +else: + def merge(*iterables: Iterable[_T]) -> Iterable[_T]: ... # type: ignore def nlargest(n: int, iterable: Iterable[_T], key: Callable[[_T], Any] = ...) -> List[_T]: ... def nsmallest(n: int, iterable: Iterable[_T],