From db4a25ce8967b1e21812f213e1585da3c1201d19 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Date: Mon, 19 May 2025 17:17:23 +0100 Subject: [PATCH] Add heapq types (#14098) --- stdlib/@tests/stubtest_allowlists/py314.txt | 5 ----- stdlib/_heapq.pyi | 12 ++++++++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/py314.txt b/stdlib/@tests/stubtest_allowlists/py314.txt index 614a875c4..286d11309 100644 --- a/stdlib/@tests/stubtest_allowlists/py314.txt +++ b/stdlib/@tests/stubtest_allowlists/py314.txt @@ -3,11 +3,6 @@ # ==================================================================== _asyncio.all_tasks -_heapq.heapify_max -_heapq.heappop_max -_heapq.heappush_max -_heapq.heappushpop_max -_heapq.heapreplace_max _imp.pyc_magic_number_token _thread.RLock.locked _thread.set_name diff --git a/stdlib/_heapq.pyi b/stdlib/_heapq.pyi index 9f731bf91..3363fbcd7 100644 --- a/stdlib/_heapq.pyi +++ b/stdlib/_heapq.pyi @@ -1,11 +1,19 @@ +import sys from typing import Any, Final, TypeVar -_T = TypeVar("_T") +_T = TypeVar("_T") # list items must be comparable __about__: Final[str] -def heapify(heap: list[Any], /) -> None: ... +def heapify(heap: list[Any], /) -> None: ... # list items must be comparable 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[Any], /) -> None: ... # list items must be comparable + 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: ... + def heapreplace_max(heap: list[_T], item: _T, /) -> _T: ...