From: David Montague Date: Mon, 14 Oct 2019 09:34:51 +0000 (-0700) Subject: Add type hint for run_in_threadpool return type X-Git-Tag: 0.12.11~14^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F674%2Fhead;p=thirdparty%2Fstarlette.git Add type hint for run_in_threadpool return type --- diff --git a/starlette/concurrency.py b/starlette/concurrency.py index 56db3db3..c5ac039e 100644 --- a/starlette/concurrency.py +++ b/starlette/concurrency.py @@ -8,10 +8,12 @@ try: except ImportError: # pragma: no cover contextvars = None # type: ignore +T = typing.TypeVar("T") + async def run_in_threadpool( - func: typing.Callable, *args: typing.Any, **kwargs: typing.Any -) -> typing.Any: + func: typing.Callable[..., T], *args: typing.Any, **kwargs: typing.Any +) -> T: loop = asyncio.get_event_loop() if contextvars is not None: # pragma: no cover # Ensure we run in the same context