mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
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:
parent
2ec588d2a6
commit
a6a47c0b44
@ -6,6 +6,5 @@
|
|||||||
"dependencies": ["network"],
|
"dependencies": ["network"],
|
||||||
"documentation": "https://www.home-assistant.io/integrations/emulated_hue",
|
"documentation": "https://www.home-assistant.io/integrations/emulated_hue",
|
||||||
"iot_class": "local_push",
|
"iot_class": "local_push",
|
||||||
"quality_scale": "internal",
|
"quality_scale": "internal"
|
||||||
"requirements": ["aiohttp_cors==0.7.0"]
|
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ from aiohttp.web_urldispatcher import (
|
|||||||
ResourceRoute,
|
ResourceRoute,
|
||||||
StaticResource,
|
StaticResource,
|
||||||
)
|
)
|
||||||
|
import aiohttp_cors
|
||||||
|
|
||||||
from homeassistant.const import HTTP_HEADER_X_REQUESTED_WITH
|
from homeassistant.const import HTTP_HEADER_X_REQUESTED_WITH
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
@ -35,11 +36,6 @@ VALID_CORS_TYPES: Final = (Resource, ResourceRoute, StaticResource)
|
|||||||
@callback
|
@callback
|
||||||
def setup_cors(app: Application, origins: list[str]) -> None:
|
def setup_cors(app: Application, origins: list[str]) -> None:
|
||||||
"""Set up CORS."""
|
"""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(
|
cors = aiohttp_cors.setup(
|
||||||
app,
|
app,
|
||||||
defaults={
|
defaults={
|
||||||
|
@ -5,10 +5,5 @@
|
|||||||
"documentation": "https://www.home-assistant.io/integrations/http",
|
"documentation": "https://www.home-assistant.io/integrations/http",
|
||||||
"integration_type": "system",
|
"integration_type": "system",
|
||||||
"iot_class": "local_push",
|
"iot_class": "local_push",
|
||||||
"quality_scale": "internal",
|
"quality_scale": "internal"
|
||||||
"requirements": [
|
|
||||||
"aiohttp_cors==0.7.0",
|
|
||||||
"aiohttp-fast-url-dispatcher==0.3.0",
|
|
||||||
"aiohttp-zlib-ng==0.3.1"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
@ -262,16 +262,6 @@ aioharmony==0.2.10
|
|||||||
# homeassistant.components.homekit_controller
|
# homeassistant.components.homekit_controller
|
||||||
aiohomekit==3.1.5
|
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
|
# homeassistant.components.hue
|
||||||
aiohue==4.7.1
|
aiohue==4.7.1
|
||||||
|
|
||||||
|
@ -238,16 +238,6 @@ aioharmony==0.2.10
|
|||||||
# homeassistant.components.homekit_controller
|
# homeassistant.components.homekit_controller
|
||||||
aiohomekit==3.1.5
|
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
|
# homeassistant.components.hue
|
||||||
aiohue==4.7.1
|
aiohue==4.7.1
|
||||||
|
|
||||||
|
@ -591,7 +591,7 @@ async def test_discovery_requirements_mqtt(hass: HomeAssistant) -> None:
|
|||||||
) as mock_process:
|
) as mock_process:
|
||||||
await async_get_integration_with_requirements(hass, "mqtt_comp")
|
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
|
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:
|
) as mock_process:
|
||||||
await async_get_integration_with_requirements(hass, "ssdp_comp")
|
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[0][1][1] == ssdp.requirements
|
||||||
assert {
|
assert {
|
||||||
mock_process.mock_calls[1][1][0],
|
mock_process.mock_calls[1][1][0],
|
||||||
mock_process.mock_calls[2][1][0],
|
mock_process.mock_calls[2][1][0],
|
||||||
mock_process.mock_calls[3][1][0],
|
} == {"network", "recorder"}
|
||||||
} == {"http", "network", "recorder"}
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
@ -638,7 +637,7 @@ async def test_discovery_requirements_zeroconf(
|
|||||||
) as mock_process:
|
) as mock_process:
|
||||||
await async_get_integration_with_requirements(hass, "comp")
|
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
|
assert mock_process.mock_calls[0][1][1] == zeroconf.requirements
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user