From 86218a52b7513b326d3e6e761d18b6ed2230c76c Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Sun, 6 Aug 2023 14:02:48 +0300 Subject: [PATCH] Add `get_context` methods to `asyncio` in 3.12 (#10534) --- stdlib/asyncio/events.pyi | 2 ++ stdlib/asyncio/tasks.pyi | 2 ++ tests/stubtest_allowlists/py312.txt | 4 ---- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi index b1b0fcfa5..cde63b279 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -76,6 +76,8 @@ class Handle: def cancel(self) -> None: ... def _run(self) -> None: ... def cancelled(self) -> bool: ... + if sys.version_info >= (3, 12): + def get_context(self) -> Context: ... class TimerHandle(Handle): def __init__( diff --git a/stdlib/asyncio/tasks.pyi b/stdlib/asyncio/tasks.pyi index 8022b2ad0..5ea30d379 100644 --- a/stdlib/asyncio/tasks.pyi +++ b/stdlib/asyncio/tasks.pyi @@ -314,6 +314,8 @@ class Task(Future[_T_co], Generic[_T_co]): # type: ignore[type-var] # pyright: def get_coro(self) -> _TaskCompatibleCoro[_T_co]: ... def get_name(self) -> str: ... def set_name(self, __value: object) -> None: ... + if sys.version_info >= (3, 12): + def get_context(self) -> Context: ... def get_stack(self, *, limit: int | None = None) -> list[FrameType]: ... def print_stack(self, *, limit: int | None = None, file: TextIO | None = None) -> None: ... diff --git a/tests/stubtest_allowlists/py312.txt b/tests/stubtest_allowlists/py312.txt index 15e16684b..26084d535 100644 --- a/tests/stubtest_allowlists/py312.txt +++ b/tests/stubtest_allowlists/py312.txt @@ -2,17 +2,13 @@ argparse.BooleanOptionalAction.__init__ asyncio.BaseEventLoop.create_connection asyncio.BaseEventLoop.shutdown_default_executor -asyncio.Handle.get_context asyncio.StreamWriter.start_tls -asyncio.Task.get_context asyncio.base_events.BaseEventLoop.create_connection asyncio.base_events.BaseEventLoop.shutdown_default_executor asyncio.constants.THREAD_JOIN_TIMEOUT asyncio.create_eager_task_factory asyncio.eager_task_factory -asyncio.events.Handle.get_context asyncio.streams.StreamWriter.start_tls -asyncio.tasks.Task.get_context asyncio.tasks.__all__ asyncio.tasks.create_eager_task_factory asyncio.tasks.eager_task_factory