1
0
mirror of https://github.com/home-assistant/core synced 2024-07-05 17:29:15 +00:00

Bump aiohttp to 3.9.1 (#104176)

This commit is contained in:
J. Nick Koston 2023-11-29 09:13:54 -06:00 committed by GitHub
parent ba481001c3
commit 608f4f7c52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 18 additions and 37 deletions

View File

@ -6,6 +6,7 @@ from http import HTTPStatus
import logging
import os
import re
from typing import TYPE_CHECKING
from urllib.parse import quote, unquote
import aiohttp
@ -156,6 +157,9 @@ class HassIOView(HomeAssistantView):
# _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
if TYPE_CHECKING:
# pylint: disable-next=protected-access
assert isinstance(request._stored_content_type, str)
# pylint: disable-next=protected-access
headers[CONTENT_TYPE] = request._stored_content_type

View File

@ -172,7 +172,7 @@ class HassIOIngress(HomeAssistantView):
content_length = result.headers.get(hdrs.CONTENT_LENGTH, UNDEFINED)
# Avoid parsing content_type in simple cases for better performance
if maybe_content_type := result.headers.get(hdrs.CONTENT_TYPE):
content_type = (maybe_content_type.partition(";"))[0].strip()
content_type: str = (maybe_content_type.partition(";"))[0].strip()
else:
content_type = result.content_type
# Simple request

View File

@ -298,7 +298,7 @@ def _async_get_connector(
return connectors[connector_key]
if verify_ssl:
ssl_context: bool | SSLContext = ssl_util.get_default_context()
ssl_context: SSLContext = ssl_util.get_default_context()
else:
ssl_context = ssl_util.get_default_no_verify_context()

View File

@ -3,8 +3,7 @@
aiodiscover==1.5.1
aiohttp-fast-url-dispatcher==0.3.0
aiohttp-zlib-ng==0.1.1
aiohttp==3.8.5;python_version<'3.12'
aiohttp==3.9.0;python_version>='3.12'
aiohttp==3.9.1
aiohttp_cors==0.7.0
astral==2.2
async-upnp-client==0.36.2

View File

@ -23,8 +23,7 @@ classifiers = [
]
requires-python = ">=3.11.0"
dependencies = [
"aiohttp==3.9.0;python_version>='3.12'",
"aiohttp==3.8.5;python_version<'3.12'",
"aiohttp==3.9.1",
"aiohttp_cors==0.7.0",
"aiohttp-fast-url-dispatcher==0.3.0",
"aiohttp-zlib-ng==0.1.1",

View File

@ -3,8 +3,7 @@
-c homeassistant/package_constraints.txt
# Home Assistant Core
aiohttp==3.9.0;python_version>='3.12'
aiohttp==3.8.5;python_version<'3.12'
aiohttp==3.9.1
aiohttp_cors==0.7.0
aiohttp-fast-url-dispatcher==0.3.0
aiohttp-zlib-ng==0.1.1

View File

@ -1,7 +1,6 @@
"""The tests for generic camera component."""
import asyncio
from http import HTTPStatus
import sys
from unittest.mock import patch
import aiohttp
@ -164,17 +163,10 @@ async def test_limit_refetch(
hass.states.async_set("sensor.temp", "5")
# TODO: Remove version check with aiohttp 3.9.0
if sys.version_info >= (3, 12):
with pytest.raises(aiohttp.ServerTimeoutError), patch(
"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")
with pytest.raises(aiohttp.ServerTimeoutError), patch(
"asyncio.timeout", side_effect=asyncio.TimeoutError()
):
resp = await client.get("/api/camera_proxy/camera.config_test")
assert respx.calls.call_count == 1
assert resp.status == HTTPStatus.OK

View File

@ -1,5 +1,4 @@
"""Test aiohttp request helper."""
import sys
from aiohttp import web
@ -50,22 +49,11 @@ def test_serialize_text() -> None:
def test_serialize_body_str() -> None:
"""Test serializing a response with a str as body."""
response = web.Response(status=201, body="Hello")
# TODO: Remove version check with aiohttp 3.9.0
if sys.version_info >= (3, 12):
assert aiohttp.serialize_response(response) == {
"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",
},
}
assert aiohttp.serialize_response(response) == {
"status": 201,
"body": "Hello",
"headers": {"Content-Type": "text/plain; charset=utf-8"},
}
def test_serialize_body_None() -> None: