The _compat module is used for code which requires branching between different
Python environments. It is excluded from the code coverage checks.
"""
+import asyncio
import ssl
import sys
+import typing
+
+if typing.TYPE_CHECKING: # pragma: no cover
+ import typing_extensions
# Brotli support is optional
# The C bindings in `brotli` are recommended for CPython.
context.options |= ssl.OP_NO_SSLv3
context.options |= ssl.OP_NO_TLSv1
context.options |= ssl.OP_NO_TLSv1_1
+
+
+def iscoroutine(coro: object) -> "typing_extensions.TypeGuard[typing.Coroutine]":
+ # Drop when this is resolved: https://github.com/python/typeshed/pull/8104
+ return asyncio.iscoroutine(coro)
-import asyncio
import typing
+from .._compat import iscoroutine
from .._models import Request, Response
from .base import AsyncBaseTransport, BaseTransport
# return the result.
# https://simonwillison.net/2020/Sep/2/await-me-maybe/
- if asyncio.iscoroutine(response):
+ if iscoroutine(response):
response = await response
return response