mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Report unmet dependencies for failing config flows (#65061)
* Report unmet dependencies for failing config flows * Apply suggestions from code review Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Update homeassistant/setup.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Modify error message * Add test Co-authored-by: Martin Hjelmare <marhje52@gmail.com> Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
@@ -18,7 +18,7 @@ from .const import (
|
||||
Platform,
|
||||
)
|
||||
from .core import CALLBACK_TYPE
|
||||
from .exceptions import HomeAssistantError
|
||||
from .exceptions import DependencyError, HomeAssistantError
|
||||
from .helpers.typing import ConfigType
|
||||
from .util import dt as dt_util, ensure_unique_string
|
||||
|
||||
@@ -83,8 +83,11 @@ async def async_setup_component(
|
||||
|
||||
async def _async_process_dependencies(
|
||||
hass: core.HomeAssistant, config: ConfigType, integration: loader.Integration
|
||||
) -> bool:
|
||||
"""Ensure all dependencies are set up."""
|
||||
) -> list[str]:
|
||||
"""Ensure all dependencies are set up.
|
||||
|
||||
Returns a list of dependencies which failed to set up.
|
||||
"""
|
||||
dependencies_tasks = {
|
||||
dep: hass.loop.create_task(async_setup_component(hass, dep, config))
|
||||
for dep in integration.dependencies
|
||||
@@ -104,7 +107,7 @@ async def _async_process_dependencies(
|
||||
)
|
||||
|
||||
if not dependencies_tasks and not after_dependencies_tasks:
|
||||
return True
|
||||
return []
|
||||
|
||||
if dependencies_tasks:
|
||||
_LOGGER.debug(
|
||||
@@ -135,8 +138,7 @@ async def _async_process_dependencies(
|
||||
", ".join(failed),
|
||||
)
|
||||
|
||||
return False
|
||||
return True
|
||||
return failed
|
||||
|
||||
|
||||
async def _async_setup_component(
|
||||
@@ -341,8 +343,8 @@ async def async_process_deps_reqs(
|
||||
elif integration.domain in processed:
|
||||
return
|
||||
|
||||
if not await _async_process_dependencies(hass, config, integration):
|
||||
raise HomeAssistantError("Could not set up all dependencies.")
|
||||
if failed_deps := await _async_process_dependencies(hass, config, integration):
|
||||
raise DependencyError(failed_deps)
|
||||
|
||||
if not hass.config.skip_pip and integration.requirements:
|
||||
async with hass.timeout.async_freeze(integration.domain):
|
||||
|
||||
Reference in New Issue
Block a user