Make the _sync_await type more precise
# limitations under the License.
import asyncio
import sys
-from typing import Any, Awaitable
+from typing import Awaitable, TypeVar
# If we are not running on Python 3.7 or later, we need to swap the Python implementation of Task in for the C
# implementation in order to support synchronous invokes.
@@ -37,8 +37,10 @@ else:
_all_tasks = asyncio.all_tasks # type: ignore
_get_current_task = asyncio.current_task # type: ignore
+T = TypeVar("T")
-def _sync_await(awaitable: Awaitable[Any]) -> Any:
+
+def _sync_await(awaitable: Awaitable[T]) -> T:
"""
_sync_await waits for the given future to complete by effectively yielding the current task and pumping the event
loop.
