Skip to content

Commit

Permalink
Fixed return type annotation for BlockingPortal.call()
Browse files Browse the repository at this point in the history
When a coroutine function is passed, it should indicate that the return value of said coroutine, and not the coroutine object itself, is returned.
  • Loading branch information
agronholm committed Aug 17, 2020
1 parent 93f8077 commit 9069156
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/anyio/abc/threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from abc import ABCMeta, abstractmethod
from collections import Coroutine
from concurrent.futures import Future
from typing import TypeVar, Callable
from typing import TypeVar, Callable, overload, Any

T_Retval = TypeVar('T_Retval')

Expand Down Expand Up @@ -82,7 +82,15 @@ async def _call_func(self, func: Callable, args: tuple, future: Future) -> None:
def _spawn_task_from_thread(self, func: Callable, args: tuple, future: Future) -> None:
pass

@overload
def call(self, func: Callable[..., Coroutine[Any, Any, T_Retval]], *args) -> T_Retval:
...

@overload
def call(self, func: Callable[..., T_Retval], *args) -> T_Retval:
...

def call(self, func, *args):
"""
Call the given function in the event loop thread.
Expand Down

0 comments on commit 9069156

Please sign in to comment.