]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Remove typeshed iscoroutine workaround (#2466)
authorAdrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
Tue, 29 Nov 2022 08:45:10 +0000 (02:45 -0600)
committerGitHub <noreply@github.com>
Tue, 29 Nov 2022 08:45:10 +0000 (02:45 -0600)
This was resolved in typeshed and newer mypy versions have inherited the fix.

Co-authored-by: Martijn Pieters <mj@zopatista.com>
httpx/_compat.py
httpx/_transports/mock.py

index 533fab46cfda81408f497542e6646aa4c6f12e26..6d96ad27a1bc74b3c1a7b1d70340aa78b22da401 100644 (file)
@@ -2,13 +2,8 @@
 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.
@@ -43,8 +38,3 @@ else:
         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)
index 4ff4913df0410d3f279544f2f27ff78f8d20a344..f61aee710114cb0b3740abd7c55eba2dfc5d2a92 100644 (file)
@@ -1,6 +1,6 @@
+import asyncio
 import typing
 
-from .._compat import iscoroutine
 from .._models import Request, Response
 from .base import AsyncBaseTransport, BaseTransport
 
@@ -28,7 +28,7 @@ class MockTransport(AsyncBaseTransport, BaseTransport):
         # return the result.
 
         # https://simonwillison.net/2020/Sep/2/await-me-maybe/
-        if iscoroutine(response):
+        if asyncio.iscoroutine(response):
             response = await response
 
         return response