From: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 19 Jun 2022 10:50:04 +0000 (+0200) Subject: Bump mypy from 0.910 to 0.961 (#2269) X-Git-Tag: 0.23.1~55 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=344e01e98ae528332960d34c3eca98f5472eeabf;p=thirdparty%2Fhttpx.git Bump mypy from 0.910 to 0.961 (#2269) * Bump mypy from 0.910 to 0.961 Bumps [mypy](https://github.com/python/mypy) from 0.910 to 0.961. - [Release notes](https://github.com/python/mypy/releases) - [Commits](https://github.com/python/mypy/compare/v0.910...v0.961) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Handle py37 iscoroutine type guard oddity Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: florimondmanca --- diff --git a/httpx/_compat.py b/httpx/_compat.py index 6d96ad27..533fab46 100644 --- a/httpx/_compat.py +++ b/httpx/_compat.py @@ -2,8 +2,13 @@ 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. @@ -38,3 +43,8 @@ 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 f61aee71..4ff4913d 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 asyncio.iscoroutine(response): + if iscoroutine(response): response = await response return response diff --git a/requirements.txt b/requirements.txt index 75077c49..cffe00d0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -27,7 +27,7 @@ flake8==3.9.2 flake8-bugbear==22.4.25 flake8-pie==0.15.0; python_version>='3.7' isort==5.10.1 -mypy==0.910 +mypy==0.961 types-certifi==2021.10.8.2 pytest==7.1.2 pytest-asyncio==0.18.3