From 3bcde6c2315742e5661e76eed810000e77ed7111 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sun, 8 Oct 2023 01:15:02 +0200 Subject: [PATCH 1/2] Update aiohttp to 3.9.0b0 --- homeassistant/package_constraints.txt | 2 +- pyproject.toml | 2 +- requirements.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index 799de88f8e0b17..0a299d50239a46 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -1,5 +1,5 @@ aiodiscover==1.5.1 -aiohttp==3.8.6 +aiohttp==3.9.0b0 aiohttp_cors==0.7.0 astral==2.2 async-upnp-client==0.36.1 diff --git a/pyproject.toml b/pyproject.toml index 7badc6be1e4e2f..0bae2c942d71a0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ classifiers = [ ] requires-python = ">=3.11.0" dependencies = [ - "aiohttp==3.8.6", + "aiohttp==3.9.0b0", "astral==2.2", "attrs==23.1.0", "atomicwrites-homeassistant==1.4.1", diff --git a/requirements.txt b/requirements.txt index a7ede68c9ecca1..62c5ab5aedee2a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ -c homeassistant/package_constraints.txt # Home Assistant Core -aiohttp==3.8.6 +aiohttp==3.9.0b0 astral==2.2 attrs==23.1.0 atomicwrites-homeassistant==1.4.1 From 0daab5ea607eaea68be6cbbcb6aa72f52e06507a Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 15 Aug 2023 11:37:39 +0200 Subject: [PATCH 2/2] Fix issues --- homeassistant/components/hassio/http.py | 5 ++--- homeassistant/helpers/aiohttp_client.py | 14 ++++++++++++-- tests/components/generic/test_camera.py | 2 +- tests/util/test_aiohttp.py | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/hassio/http.py b/homeassistant/components/hassio/http.py index 5bcdb6896cdfac..84b49af11c2fcf 100644 --- a/homeassistant/components/hassio/http.py +++ b/homeassistant/components/hassio/http.py @@ -156,9 +156,8 @@ async def _handle(self, request: web.Request, path: str) -> web.StreamResponse: # _stored_content_type is only computed once `content_type` is accessed if path == "backups/new/upload": # We need to reuse the full content type that includes the boundary - headers[ - CONTENT_TYPE - ] = request._stored_content_type # pylint: disable=protected-access + # pylint: disable-next=protected-access + headers[CONTENT_TYPE] = request._stored_content_type # type: ignore[assignment] try: client = await self._websession.request( diff --git a/homeassistant/helpers/aiohttp_client.py b/homeassistant/helpers/aiohttp_client.py index ac253d492547f9..1948d3bca95d7d 100644 --- a/homeassistant/helpers/aiohttp_client.py +++ b/homeassistant/helpers/aiohttp_client.py @@ -4,7 +4,6 @@ import asyncio from collections.abc import Awaitable, Callable from contextlib import suppress -from ssl import SSLContext import sys from types import MappingProxyType from typing import TYPE_CHECKING, Any, cast @@ -59,6 +58,17 @@ MAXIMUM_CONNECTIONS_PER_HOST = 100 +# Overwrite base aiohttp _wait implementation +# Homeassistant has a custom shutdown wait logic. +async def _noop_wait(*args: Any, **kwargs: Any) -> None: + """Do nothing.""" + return + + +# pylint: disable-next=protected-access +web.BaseSite._wait = _noop_wait # type: ignore[method-assign] + + class HassClientResponse(aiohttp.ClientResponse): """aiohttp.ClientResponse with a json method that uses json_loads by default.""" @@ -276,7 +286,7 @@ def _async_get_connector( return cast(aiohttp.BaseConnector, hass.data[key]) if verify_ssl: - ssl_context: bool | SSLContext = ssl_util.get_default_context() + ssl_context = ssl_util.get_default_context() else: ssl_context = ssl_util.get_default_no_verify_context() diff --git a/tests/components/generic/test_camera.py b/tests/components/generic/test_camera.py index f7f7c390e0d6a1..8bfd0a66dd5eae 100644 --- a/tests/components/generic/test_camera.py +++ b/tests/components/generic/test_camera.py @@ -164,7 +164,7 @@ async def test_limit_refetch( hass.states.async_set("sensor.temp", "5") with pytest.raises(aiohttp.ServerTimeoutError), patch( - "async_timeout.timeout", side_effect=asyncio.TimeoutError() + "asyncio.timeout", side_effect=asyncio.TimeoutError() ): resp = await client.get("/api/camera_proxy/camera.config_test") diff --git a/tests/util/test_aiohttp.py b/tests/util/test_aiohttp.py index 76394b42491cf0..496e6373ba535e 100644 --- a/tests/util/test_aiohttp.py +++ b/tests/util/test_aiohttp.py @@ -51,7 +51,7 @@ def test_serialize_body_str() -> None: assert aiohttp.serialize_response(response) == { "status": 201, "body": "Hello", - "headers": {"Content-Length": "5", "Content-Type": "text/plain; charset=utf-8"}, + "headers": {"Content-Type": "text/plain; charset=utf-8"}, }