Skip to content
Myr

Remove typeshed iscoroutine workaround (#2466)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

This was resolved in typeshed and newer mypy versions have inherited the fix.

authored by Adrian Garcia Badaracco · committed by GitHub · parent 1ba3e2a · Browse files · 2 files+2 added−12 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Martijn Pieters <mj@zopatista.com>

Diff stats

2 files+2 added−12 removed

  • other:+2 added−12 removed

2 files+2 added−12 removed

modified:httpx/_transports/mock.py+2 added-2 removed
1import asyncio2import typing33from .._compat import iscoroutine4from .._models import Request, Response5from .base import AsyncBaseTransport, BaseTransport67
19 unmodified lines
27 # If it is, then the `response` variable need to be awaited to actually28 # return the result.2930 # https://simonwillison.net/2020/Sep/2/await-me-maybe/31 if iscoroutine(response):31 if asyncio.iscoroutine(response):32 response = await response3334 return response
modified:httpx/_compat.py-10 removed
1"""2The _compat module is used for code which requires branching between different3Python environments. It is excluded from the code coverage checks.4"""5import asyncio5import ssl6import sys8import typing710if typing.TYPE_CHECKING: # pragma: no cover11 import typing_extensions128# Brotli support is optional9# The C bindings in `brotli` are recommended for CPython.10# The CFFI bindings in `brotlicffi` are recommended for PyPy and everything else.11try:
25 unmodified lines
37 context.options |= ssl.OP_NO_SSLv238 context.options |= ssl.OP_NO_SSLv339 context.options |= ssl.OP_NO_TLSv140 context.options |= ssl.OP_NO_TLSv1_1464748def iscoroutine(coro: object) -> "typing_extensions.TypeGuard[typing.Coroutine]":49 # Drop when this is resolved: https://github.com/python/typeshed/pull/810450 return asyncio.iscoroutine(coro)