Deduplicate some code in helpers.check_config.async_check_ha_config_file (#103852)

Tweak helpers.check_config.async_check_ha_config_file
This commit is contained in:
Erik Montnemery 2023-11-12 19:15:01 +01:00 committed by GitHub
parent 1168956f8c
commit 51b599e1f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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