From: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com> Date: Tue, 29 Nov 2022 08:45:10 +0000 (-0600) Subject: Remove typeshed iscoroutine workaround (#2466) X-Git-Tag: 0.23.2~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=75a13a15aa8fea10367b791747a89463a978fa3e;p=thirdparty%2Fhttpx.git Remove typeshed iscoroutine workaround (#2466) This was resolved in typeshed and newer mypy versions have inherited the fix. Co-authored-by: Martijn Pieters --- diff --git a/httpx/_compat.py b/httpx/_compat.py index 533fab46..6d96ad27 100644 --- a/httpx/_compat.py +++ b/httpx/_compat.py @@ -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) diff --git a/httpx/_transports/mock.py b/httpx/_transports/mock.py index 4ff4913d..f61aee71 100644 --- a/httpx/_transports/mock.py +++ b/httpx/_transports/mock.py @@ -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