Skip to content
Open
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
9 changes: 6 additions & 3 deletions stdlib/_heapq.pyi
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import sys
from _typeshed import SupportsRichComparisonT as _T # All type variable use in this module requires comparability.
from _typeshed import ( # All type variable use in this module requires comparability.
SupportsRichComparison,
SupportsRichComparisonT as _T,
)
from typing import Final

__about__: Final[str]

def heapify(heap: list[_T], /) -> None: ...
def heapify(heap: list[SupportsRichComparison], /) -> None: ...
def heappop(heap: list[_T], /) -> _T: ...
def heappush(heap: list[_T], item: _T, /) -> None: ...
def heappushpop(heap: list[_T], item: _T, /) -> _T: ...
def heapreplace(heap: list[_T], item: _T, /) -> _T: ...

if sys.version_info >= (3, 14):
def heapify_max(heap: list[_T], /) -> None: ...
def heapify_max(heap: list[SupportsRichComparison], /) -> None: ...
def heappop_max(heap: list[_T], /) -> _T: ...
def heappush_max(heap: list[_T], item: _T, /) -> None: ...
def heappushpop_max(heap: list[_T], item: _T, /) -> _T: ...
Expand Down
23 changes: 15 additions & 8 deletions stdlib/heapq.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import sys
from _heapq import *
from _typeshed import SupportsRichComparison
from _typeshed import SupportsRichComparison, SupportsRichComparisonT as _T
from collections.abc import Callable, Generator, Iterable
from typing import Any, Final, TypeVar
from typing import Final, TypeVar, overload

__all__ = ["heappush", "heappop", "heapify", "heapreplace", "merge", "nlargest", "nsmallest", "heappushpop"]

Expand All @@ -14,9 +14,16 @@ _S = TypeVar("_S")

__about__: Final[str]

def merge(
*iterables: Iterable[_S], key: Callable[[_S], SupportsRichComparison] | None = None, reverse: bool = False
) -> Generator[_S]: ...
def nlargest(n: int, iterable: Iterable[_S], key: Callable[[_S], SupportsRichComparison] | None = None) -> list[_S]: ...
def nsmallest(n: int, iterable: Iterable[_S], key: Callable[[_S], SupportsRichComparison] | None = None) -> list[_S]: ...
def _heapify_max(heap: list[Any], /) -> None: ... # undocumented
@overload
def merge(*iterables: Iterable[_S], key: Callable[[_S], SupportsRichComparison], reverse: bool = False) -> Generator[_S]: ...
@overload
def merge(*iterables: Iterable[_T], key: None = None, reverse: bool = False) -> Generator[_T]: ...
@overload
def nlargest(n: int, iterable: Iterable[_S], key: Callable[[_S], SupportsRichComparison]) -> list[_S]: ...
@overload
def nlargest(n: int, iterable: Iterable[_T], key: None = None) -> list[_T]: ...
@overload
def nsmallest(n: int, iterable: Iterable[_S], key: Callable[[_S], SupportsRichComparison]) -> list[_S]: ...
@overload
def nsmallest(n: int, iterable: Iterable[_T], key: None = None) -> list[_T]: ...
def _heapify_max(heap: list[SupportsRichComparison], /) -> None: ... # undocumented