Skip to content

Commit

Permalink
Used ParamSpec in Trio's _call_in_runner_task()
Browse files Browse the repository at this point in the history
  • Loading branch information
agronholm committed Dec 16, 2023
1 parent 6257a92 commit 8fbbf44
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/anyio/_backends/_trio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -72,6 +77,7 @@
T_Retval = TypeVar("T_Retval")
T_SockAddr = TypeVar("T_SockAddr", str, IPSockAddrType)
PosArgsT = TypeVarTuple("PosArgsT")
P = ParamSpec("P")


#
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 8fbbf44

Please sign in to comment.