From f7b9b0da0e58f7bf71ead5278cf36873e89e4fea Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 16 Feb 2024 01:07:39 -0600 Subject: [PATCH] Migrate dependencies loader to use async_get_integrations (#110690) --- homeassistant/loader.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/homeassistant/loader.py b/homeassistant/loader.py index 4abcd8f2c06b62..bc795a42e4149f 100644 --- a/homeassistant/loader.py +++ b/homeassistant/loader.py @@ -1140,16 +1140,21 @@ async def _async_component_dependencies( integration: Integration, ) -> set[str]: """Get component dependencies.""" - loading = set() - loaded = set() + loading: set[str] = set() + loaded: set[str] = set() async def component_dependencies_impl(integration: Integration) -> None: """Recursively get component dependencies.""" domain = integration.domain - loading.add(domain) + if not (dependencies := integration.dependencies): + loaded.add(domain) + return - for dependency_domain in integration.dependencies: - dep_integration = await async_get_integration(hass, dependency_domain) + loading.add(domain) + dep_integrations = await async_get_integrations(hass, dependencies) + for dependency_domain, dep_integration in dep_integrations.items(): + if isinstance(dep_integration, Exception): + raise dep_integration # If we are already loading it, we have a circular dependency. # We have to check it here to make sure that every integration that @@ -1166,7 +1171,6 @@ async def component_dependencies_impl(integration: Integration) -> None: raise CircularDependency(dependency_domain, domain) await component_dependencies_impl(dep_integration) - loading.remove(domain) loaded.add(domain)