From 51b599e1f62c224ffa682772a8524bfda496888d Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Sun, 12 Nov 2023 19:15:01 +0100 Subject: [PATCH] Deduplicate some code in `helpers.check_config.async_check_ha_config_file` (#103852) Tweak helpers.check_config.async_check_ha_config_file --- homeassistant/helpers/check_config.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/homeassistant/helpers/check_config.py b/homeassistant/helpers/check_config.py index c333bab782b..441381f9994 100644 --- a/homeassistant/helpers/check_config.py +++ b/homeassistant/helpers/check_config.py @@ -100,16 +100,13 @@ async def async_check_ha_config_file( # noqa: C901 pack_config = core_config[CONF_PACKAGES].get(package, config) result.add_warning(message, domain, pack_config) - def _comp_error(ex: Exception, domain: str, config: ConfigType) -> None: + def _comp_error(ex: Exception, domain: str, component_config: ConfigType) -> None: """Handle errors from components: async_log_exception.""" + message = _format_config_error(ex, domain, component_config)[0] if domain in frontend_dependencies: - result.add_error( - _format_config_error(ex, domain, config)[0], domain, config - ) + result.add_error(message, domain, component_config) else: - result.add_warning( - _format_config_error(ex, domain, config)[0], domain, config - ) + result.add_warning(message, domain, component_config) async def _get_integration( hass: HomeAssistant, domain: str