diff --git a/Lib/asyncio/staggered.py b/Lib/asyncio/staggered.py index 451a53a16f3831..4605fefb530d62 100644 --- a/Lib/asyncio/staggered.py +++ b/Lib/asyncio/staggered.py @@ -3,7 +3,8 @@ __all__ = 'staggered_race', import contextlib -import typing +from collections.abc import Awaitable, Callable, Iterable +from typing import Any from . import events from . import exceptions as exceptions_mod @@ -12,14 +13,14 @@ async def staggered_race( - coro_fns: typing.Iterable[typing.Callable[[], typing.Awaitable]], - delay: typing.Optional[float], + coro_fns: Iterable[Callable[[], Awaitable[Any]]], + delay: float | None, *, - loop: events.AbstractEventLoop = None, -) -> typing.Tuple[ - typing.Any, - typing.Optional[int], - typing.List[typing.Optional[Exception]] + loop: events.AbstractEventLoop | None = None, +) -> tuple[ + Any, + int | None, + list[Exception | None] ]: """Run coroutines with staggered start times and take the first to finish. diff --git a/Misc/NEWS.d/next/Library/2024-01-19-12-05-22.gh-issue-114281.H5JQe4.rst b/Misc/NEWS.d/next/Library/2024-01-19-12-05-22.gh-issue-114281.H5JQe4.rst new file mode 100644 index 00000000000000..a50c5b14ba0111 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-01-19-12-05-22.gh-issue-114281.H5JQe4.rst @@ -0,0 +1 @@ +Improve type hints in ``Lib/asyncio/staggered.py``.