From 47d101b59755c01676cb31dcb1a318073bb59dc9 Mon Sep 17 00:00:00 2001 From: nightcityblade Date: Wed, 5 Aug 2026 11:21:32 +0800 Subject: [PATCH 1/2] [stdlib] Allow loop eager_start on Python 3.13 --- stdlib/@tests/test_cases/asyncio/check_task.py | 13 +++++++++++++ stdlib/asyncio/base_events.pyi | 3 ++- stdlib/asyncio/events.pyi | 3 ++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/stdlib/@tests/test_cases/asyncio/check_task.py b/stdlib/@tests/test_cases/asyncio/check_task.py index 69bcf8f782aa..6aca768d4b8e 100644 --- a/stdlib/@tests/test_cases/asyncio/check_task.py +++ b/stdlib/@tests/test_cases/asyncio/check_task.py @@ -1,6 +1,10 @@ from __future__ import annotations import asyncio +import sys +from asyncio.base_events import BaseEventLoop +from collections.abc import Coroutine +from typing import Any class Waiter: @@ -18,6 +22,15 @@ async def foo() -> int: return 42 +if sys.version_info >= (3, 13): + + def check_loop_create_task_eager_start( + loop: asyncio.AbstractEventLoop, base_loop: BaseEventLoop, coro: Coroutine[Any, Any, int] + ) -> None: + loop.create_task(coro, eager_start=True) + base_loop.create_task(coro, eager_start=True) + + async def main() -> None: # asyncio.Task is covariant in its type argument, which is unusual since its parent class # asyncio.Future is invariant in its type argument. This is only sound because asyncio.Task diff --git a/stdlib/asyncio/base_events.pyi b/stdlib/asyncio/base_events.pyi index 3c7d8c2ce02e..056d9a2d36c9 100644 --- a/stdlib/asyncio/base_events.pyi +++ b/stdlib/asyncio/base_events.pyi @@ -83,7 +83,8 @@ class BaseEventLoop(AbstractEventLoop): # Future methods def create_future(self) -> Future[Any]: ... # Tasks methods - if sys.version_info >= (3, 14): + # `eager_start` is supported as an arbitrary kwarg starting in 3.13.3. + if sys.version_info >= (3, 13): def create_task( self, coro: _CoroutineLike[_T], diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi index db826ff1c2e5..12978a97679f 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -161,7 +161,8 @@ class AbstractEventLoop: @abstractmethod def create_future(self) -> Future[Any]: ... # Tasks methods - if sys.version_info >= (3, 14): + # `eager_start` is supported as an arbitrary kwarg starting in 3.13.3. + if sys.version_info >= (3, 13): @abstractmethod def create_task( self, From f73f35d56954fc8e552c15261bc4588b72649331 Mon Sep 17 00:00:00 2001 From: nightcityblade Date: Fri, 7 Aug 2026 23:08:58 +0800 Subject: [PATCH 2/2] [stdlib] Remove loop eager_start regression test --- stdlib/@tests/test_cases/asyncio/check_task.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/stdlib/@tests/test_cases/asyncio/check_task.py b/stdlib/@tests/test_cases/asyncio/check_task.py index 6aca768d4b8e..69bcf8f782aa 100644 --- a/stdlib/@tests/test_cases/asyncio/check_task.py +++ b/stdlib/@tests/test_cases/asyncio/check_task.py @@ -1,10 +1,6 @@ from __future__ import annotations import asyncio -import sys -from asyncio.base_events import BaseEventLoop -from collections.abc import Coroutine -from typing import Any class Waiter: @@ -22,15 +18,6 @@ async def foo() -> int: return 42 -if sys.version_info >= (3, 13): - - def check_loop_create_task_eager_start( - loop: asyncio.AbstractEventLoop, base_loop: BaseEventLoop, coro: Coroutine[Any, Any, int] - ) -> None: - loop.create_task(coro, eager_start=True) - base_loop.create_task(coro, eager_start=True) - - async def main() -> None: # asyncio.Task is covariant in its type argument, which is unusual since its parent class # asyncio.Future is invariant in its type argument. This is only sound because asyncio.Task