mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-02 01:23:24 +08:00
Fix the definition of nsmallest() in stdlib/2 and 2and3/heapq.pyi (#3114)
Missing support of the optional "key" kwarg in nsmallest. Also fixed nlargest syntax for 2and3 which was also missing. Use a protocol for heapq.py
This commit is contained in:
committed by
Sebastian Rittau
parent
09d1055cd3
commit
40215d1fa3
@@ -1,6 +1,7 @@
|
||||
"""Stub file for the '_heapq' module."""
|
||||
|
||||
from typing import TypeVar, List
|
||||
from typing import TypeVar, List, Iterable, Any, Callable, Optional
|
||||
import sys
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
@@ -11,5 +12,6 @@ def heappush(heap: List[_T], item: _T) -> None: ...
|
||||
def heappushpop(heap: List[_T], item: _T) -> _T: ...
|
||||
def heapreplace(heap: List[_T], item: _T) -> _T:
|
||||
raise IndexError() # if list is empty
|
||||
def nlargest(a: int, b: List[_T]) -> List[_T]: ...
|
||||
def nsmallest(a: int, b: List[_T]) -> List[_T]: ...
|
||||
if sys.version_info < (3,):
|
||||
def nlargest(n: int, iterable: Iterable[_T]) -> List[_T]: ...
|
||||
def nsmallest(n: int, iterable: Iterable[_T]) -> List[_T]: ...
|
||||
|
||||
Reference in New Issue
Block a user