Bump httpx to 0.17.1 (#48388)

* Bump httpx to 0.17.1

* git add

* typing

* add test

* tweak
This commit is contained in:
J. Nick Koston 2021-03-26 22:02:01 -10:00 committed by GitHub
parent b50dcef94f
commit 79af18a8ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 4 deletions

View file

@ -39,6 +39,17 @@ def get_async_client(
return client
class HassHttpXAsyncClient(httpx.AsyncClient):
"""httpx AsyncClient that suppresses context management."""
async def __aenter__(self: HassHttpXAsyncClient) -> HassHttpXAsyncClient:
"""Prevent an integration from reopen of the client via context manager."""
return self
async def __aexit__(self, *args: Any) -> None: # pylint: disable=signature-differs
"""Prevent an integration from close of the client via context manager."""
@callback
def create_async_httpx_client(
hass: HomeAssistantType,
@ -53,7 +64,7 @@ def create_async_httpx_client(
This method must be run in the event loop.
"""
client = httpx.AsyncClient(
client = HassHttpXAsyncClient(
verify=verify_ssl,
headers={USER_AGENT: SERVER_SOFTWARE},
**kwargs,