mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Revert aiohttp to 3.8.5 for Python 3.11 (#101932)
This commit is contained in:
parent
2dfc8b9d7f
commit
02567d9bf6
@ -157,7 +157,7 @@ class HassIOView(HomeAssistantView):
|
|||||||
if path == "backups/new/upload":
|
if path == "backups/new/upload":
|
||||||
# We need to reuse the full content type that includes the boundary
|
# We need to reuse the full content type that includes the boundary
|
||||||
# pylint: disable-next=protected-access
|
# pylint: disable-next=protected-access
|
||||||
headers[CONTENT_TYPE] = request._stored_content_type # type: ignore[assignment]
|
headers[CONTENT_TYPE] = request._stored_content_type
|
||||||
|
|
||||||
try:
|
try:
|
||||||
client = await self._websession.request(
|
client = await self._websession.request(
|
||||||
|
@ -4,6 +4,7 @@ from __future__ import annotations
|
|||||||
import asyncio
|
import asyncio
|
||||||
from collections.abc import Awaitable, Callable
|
from collections.abc import Awaitable, Callable
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
|
from ssl import SSLContext
|
||||||
import sys
|
import sys
|
||||||
from types import MappingProxyType
|
from types import MappingProxyType
|
||||||
from typing import TYPE_CHECKING, Any, cast
|
from typing import TYPE_CHECKING, Any, cast
|
||||||
@ -65,8 +66,10 @@ async def _noop_wait(*args: Any, **kwargs: Any) -> None:
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable-next=protected-access
|
# TODO: Remove version check with aiohttp 3.9.0 # pylint: disable=fixme
|
||||||
web.BaseSite._wait = _noop_wait # type: ignore[method-assign]
|
if sys.version_info >= (3, 12):
|
||||||
|
# pylint: disable-next=protected-access
|
||||||
|
web.BaseSite._wait = _noop_wait # type: ignore[method-assign]
|
||||||
|
|
||||||
|
|
||||||
class HassClientResponse(aiohttp.ClientResponse):
|
class HassClientResponse(aiohttp.ClientResponse):
|
||||||
@ -286,7 +289,7 @@ def _async_get_connector(
|
|||||||
return cast(aiohttp.BaseConnector, hass.data[key])
|
return cast(aiohttp.BaseConnector, hass.data[key])
|
||||||
|
|
||||||
if verify_ssl:
|
if verify_ssl:
|
||||||
ssl_context = ssl_util.get_default_context()
|
ssl_context: bool | SSLContext = ssl_util.get_default_context()
|
||||||
else:
|
else:
|
||||||
ssl_context = ssl_util.get_default_no_verify_context()
|
ssl_context = ssl_util.get_default_no_verify_context()
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
aiodiscover==1.5.1
|
aiodiscover==1.5.1
|
||||||
aiohttp==3.9.0b0
|
aiohttp==3.8.5;python_version<'3.12'
|
||||||
|
aiohttp==3.9.0b0;python_version>='3.12'
|
||||||
aiohttp_cors==0.7.0
|
aiohttp_cors==0.7.0
|
||||||
astral==2.2
|
astral==2.2
|
||||||
async-upnp-client==0.36.1
|
async-upnp-client==0.36.1
|
||||||
|
@ -23,7 +23,8 @@ classifiers = [
|
|||||||
]
|
]
|
||||||
requires-python = ">=3.11.0"
|
requires-python = ">=3.11.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aiohttp==3.9.0b0",
|
"aiohttp==3.9.0b0;python_version>='3.12'",
|
||||||
|
"aiohttp==3.8.5;python_version<'3.12'",
|
||||||
"astral==2.2",
|
"astral==2.2",
|
||||||
"attrs==23.1.0",
|
"attrs==23.1.0",
|
||||||
"atomicwrites-homeassistant==1.4.1",
|
"atomicwrites-homeassistant==1.4.1",
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
-c homeassistant/package_constraints.txt
|
-c homeassistant/package_constraints.txt
|
||||||
|
|
||||||
# Home Assistant Core
|
# Home Assistant Core
|
||||||
aiohttp==3.9.0b0
|
aiohttp==3.9.0b0;python_version>='3.12'
|
||||||
|
aiohttp==3.8.5;python_version<'3.12'
|
||||||
astral==2.2
|
astral==2.2
|
||||||
attrs==23.1.0
|
attrs==23.1.0
|
||||||
atomicwrites-homeassistant==1.4.1
|
atomicwrites-homeassistant==1.4.1
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
"""The tests for generic camera component."""
|
"""The tests for generic camera component."""
|
||||||
import asyncio
|
import asyncio
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
|
import sys
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
@ -163,10 +164,17 @@ async def test_limit_refetch(
|
|||||||
|
|
||||||
hass.states.async_set("sensor.temp", "5")
|
hass.states.async_set("sensor.temp", "5")
|
||||||
|
|
||||||
with pytest.raises(aiohttp.ServerTimeoutError), patch(
|
# TODO: Remove version check with aiohttp 3.9.0
|
||||||
"asyncio.timeout", side_effect=asyncio.TimeoutError()
|
if sys.version_info >= (3, 12):
|
||||||
):
|
with pytest.raises(aiohttp.ServerTimeoutError), patch(
|
||||||
resp = await client.get("/api/camera_proxy/camera.config_test")
|
"asyncio.timeout", side_effect=asyncio.TimeoutError()
|
||||||
|
):
|
||||||
|
resp = await client.get("/api/camera_proxy/camera.config_test")
|
||||||
|
else:
|
||||||
|
with pytest.raises(aiohttp.ServerTimeoutError), patch(
|
||||||
|
"async_timeout.timeout", side_effect=asyncio.TimeoutError()
|
||||||
|
):
|
||||||
|
resp = await client.get("/api/camera_proxy/camera.config_test")
|
||||||
|
|
||||||
assert respx.calls.call_count == 1
|
assert respx.calls.call_count == 1
|
||||||
assert resp.status == HTTPStatus.OK
|
assert resp.status == HTTPStatus.OK
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Test aiohttp request helper."""
|
"""Test aiohttp request helper."""
|
||||||
|
import sys
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
|
||||||
from homeassistant.util import aiohttp
|
from homeassistant.util import aiohttp
|
||||||
@ -48,11 +50,22 @@ def test_serialize_text() -> None:
|
|||||||
def test_serialize_body_str() -> None:
|
def test_serialize_body_str() -> None:
|
||||||
"""Test serializing a response with a str as body."""
|
"""Test serializing a response with a str as body."""
|
||||||
response = web.Response(status=201, body="Hello")
|
response = web.Response(status=201, body="Hello")
|
||||||
assert aiohttp.serialize_response(response) == {
|
# TODO: Remove version check with aiohttp 3.9.0
|
||||||
"status": 201,
|
if sys.version_info >= (3, 12):
|
||||||
"body": "Hello",
|
assert aiohttp.serialize_response(response) == {
|
||||||
"headers": {"Content-Type": "text/plain; charset=utf-8"},
|
"status": 201,
|
||||||
}
|
"body": "Hello",
|
||||||
|
"headers": {"Content-Type": "text/plain; charset=utf-8"},
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
assert aiohttp.serialize_response(response) == {
|
||||||
|
"status": 201,
|
||||||
|
"body": "Hello",
|
||||||
|
"headers": {
|
||||||
|
"Content-Length": "5",
|
||||||
|
"Content-Type": "text/plain; charset=utf-8",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def test_serialize_body_None() -> None:
|
def test_serialize_body_None() -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user