Make aiohttp_cors a top level import (#115563)

* Make aiohttp_cors a top level import

This was moved to a late import in #27935 but there is no
longer any need to import it late in the event loop as aiohttp_cors
is listed in pyproject.toml so it will always be available

* drop requirements as they are all top level now

* drop requirements as they are all top level now

* adjust
This commit is contained in:
J. Nick Koston 2024-04-15 14:06:59 -05:00 committed by GitHub
parent 2ec588d2a6
commit a6a47c0b44
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 7 additions and 38 deletions

View File

@ -6,6 +6,5 @@
"dependencies": ["network"],
"documentation": "https://www.home-assistant.io/integrations/emulated_hue",
"iot_class": "local_push",
"quality_scale": "internal",
"requirements": ["aiohttp_cors==0.7.0"]
"quality_scale": "internal"
}

View File

@ -13,6 +13,7 @@ from aiohttp.web_urldispatcher import (
ResourceRoute,
StaticResource,
)
import aiohttp_cors
from homeassistant.const import HTTP_HEADER_X_REQUESTED_WITH
from homeassistant.core import callback
@ -35,11 +36,6 @@ VALID_CORS_TYPES: Final = (Resource, ResourceRoute, StaticResource)
@callback
def setup_cors(app: Application, origins: list[str]) -> None:
"""Set up CORS."""
# This import should remain here. That way the HTTP integration can always
# be imported by other integrations without it's requirements being installed.
# pylint: disable-next=import-outside-toplevel
import aiohttp_cors
cors = aiohttp_cors.setup(
app,
defaults={

View File

@ -5,10 +5,5 @@
"documentation": "https://www.home-assistant.io/integrations/http",
"integration_type": "system",
"iot_class": "local_push",
"quality_scale": "internal",
"requirements": [
"aiohttp_cors==0.7.0",
"aiohttp-fast-url-dispatcher==0.3.0",
"aiohttp-zlib-ng==0.3.1"
]
"quality_scale": "internal"
}

View File

@ -262,16 +262,6 @@ aioharmony==0.2.10
# homeassistant.components.homekit_controller
aiohomekit==3.1.5
# homeassistant.components.http
aiohttp-fast-url-dispatcher==0.3.0
# homeassistant.components.http
aiohttp-zlib-ng==0.3.1
# homeassistant.components.emulated_hue
# homeassistant.components.http
aiohttp_cors==0.7.0
# homeassistant.components.hue
aiohue==4.7.1

View File

@ -238,16 +238,6 @@ aioharmony==0.2.10
# homeassistant.components.homekit_controller
aiohomekit==3.1.5
# homeassistant.components.http
aiohttp-fast-url-dispatcher==0.3.0
# homeassistant.components.http
aiohttp-zlib-ng==0.3.1
# homeassistant.components.emulated_hue
# homeassistant.components.http
aiohttp_cors==0.7.0
# homeassistant.components.hue
aiohue==4.7.1

View File

@ -591,7 +591,7 @@ async def test_discovery_requirements_mqtt(hass: HomeAssistant) -> None:
) as mock_process:
await async_get_integration_with_requirements(hass, "mqtt_comp")
assert len(mock_process.mock_calls) == 2 # mqtt also depends on http
assert len(mock_process.mock_calls) == 1
assert mock_process.mock_calls[0][1][1] == mqtt.requirements
@ -608,13 +608,12 @@ async def test_discovery_requirements_ssdp(hass: HomeAssistant) -> None:
) as mock_process:
await async_get_integration_with_requirements(hass, "ssdp_comp")
assert len(mock_process.mock_calls) == 4
assert len(mock_process.mock_calls) == 3
assert mock_process.mock_calls[0][1][1] == ssdp.requirements
assert {
mock_process.mock_calls[1][1][0],
mock_process.mock_calls[2][1][0],
mock_process.mock_calls[3][1][0],
} == {"http", "network", "recorder"}
} == {"network", "recorder"}
@pytest.mark.parametrize(
@ -638,7 +637,7 @@ async def test_discovery_requirements_zeroconf(
) as mock_process:
await async_get_integration_with_requirements(hass, "comp")
assert len(mock_process.mock_calls) == 4 # zeroconf also depends on http
assert len(mock_process.mock_calls) == 3
assert mock_process.mock_calls[0][1][1] == zeroconf.requirements