diff --git a/homeassistant/components/automation/config.py b/homeassistant/components/automation/config.py index ff0fe43ea26..72fb0101b24 100644 --- a/homeassistant/components/automation/config.py +++ b/homeassistant/components/automation/config.py @@ -1,7 +1,6 @@ """Config validation helper for the automation integration.""" from __future__ import annotations -import asyncio from collections.abc import Mapping from contextlib import suppress from typing import Any @@ -255,15 +254,15 @@ async def async_validate_config_item( async def async_validate_config(hass: HomeAssistant, config: ConfigType) -> ConfigType: """Validate config.""" + # No gather here since _try_async_validate_config_item is unlikely to suspend + # and the cost of creating many tasks is not worth the benefit. automations = list( filter( lambda x: x is not None, - await asyncio.gather( - *( - _try_async_validate_config_item(hass, p_config) - for _, p_config in config_per_platform(config, DOMAIN) - ) - ), + [ + await _try_async_validate_config_item(hass, p_config) + for _, p_config in config_per_platform(config, DOMAIN) + ], ) ) diff --git a/homeassistant/helpers/condition.py b/homeassistant/helpers/condition.py index 0029a9c906b..adbaa7e3efa 100644 --- a/homeassistant/helpers/condition.py +++ b/homeassistant/helpers/condition.py @@ -1055,9 +1055,9 @@ async def async_validate_conditions_config( hass: HomeAssistant, conditions: list[ConfigType] ) -> list[ConfigType | Template]: """Validate config.""" - return await asyncio.gather( - *(async_validate_condition_config(hass, cond) for cond in conditions) - ) + # No gather here because async_validate_condition_config is unlikely + # to suspend and the overhead of creating many tasks is not worth it + return [await async_validate_condition_config(hass, cond) for cond in conditions] @callback diff --git a/homeassistant/helpers/script.py b/homeassistant/helpers/script.py index f2eee513790..ee5015ad862 100644 --- a/homeassistant/helpers/script.py +++ b/homeassistant/helpers/script.py @@ -274,9 +274,9 @@ async def async_validate_actions_config( hass: HomeAssistant, actions: list[ConfigType] ) -> list[ConfigType]: """Validate a list of actions.""" - return await asyncio.gather( - *(async_validate_action_config(hass, action) for action in actions) - ) + # No gather here because async_validate_action_config is unlikely + # to suspend and the overhead of creating many tasks is not worth it + return [await async_validate_action_config(hass, action) for action in actions] async def async_validate_action_config(