From 8fbbf44eb528c51568178ff3ccc4dcf2d2015e6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Sat, 16 Dec 2023 12:48:12 +0200 Subject: [PATCH] Used ParamSpec in Trio's _call_in_runner_task() --- src/anyio/_backends/_trio.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/anyio/_backends/_trio.py b/src/anyio/_backends/_trio.py index eb4472f0..71e257a2 100644 --- a/src/anyio/_backends/_trio.py +++ b/src/anyio/_backends/_trio.py @@ -62,6 +62,11 @@ from ..abc._eventloop import AsyncBackend from ..streams.memory import MemoryObjectSendStream +if sys.version_info >= (3, 10): + from typing import ParamSpec +else: + from typing_extensions import ParamSpec + if sys.version_info >= (3, 11): from typing import TypeVarTuple, Unpack else: @@ -72,6 +77,7 @@ T_Retval = TypeVar("T_Retval") T_SockAddr = TypeVar("T_SockAddr", str, IPSockAddrType) PosArgsT = TypeVarTuple("PosArgsT") +P = ParamSpec("P") # @@ -764,9 +770,9 @@ def _main_task_finished(self, outcome: object) -> None: def _call_in_runner_task( self, - func: Callable[[Unpack[PosArgsT]], Awaitable[T_Retval]], - *args: Unpack[PosArgsT], - **kwargs: object, + func: Callable[P, Awaitable[T_Retval]], + *args: P.args, + **kwargs: P.kwargs, ) -> T_Retval: if self._send_stream is None: trio.lowlevel.start_guest_run(