Avoid trying to import platforms that do not exist (#112028)
* Avoid trying to import platforms that do not exist * adjust * fixes * cleanup * cleanup * cleanup * Apply suggestions from code review * docs * fixes * fixes * comment * coverage * coverage * coverage * Switch config to use async_get_component This was another path where integrations that were marked to load in the executor would be loaded in the loop * Switch config to use async_get_component/async_get_platform This was another path where integrations that were marked to load in the executor would be loaded in the loop * merge * refactor * refactor * coverage * preen * preen
This commit is contained in:
parent
a253991c6d
commit
c8cb0ff61d
9 changed files with 135 additions and 16 deletions
|
@ -1432,22 +1432,24 @@ async def async_process_component_config( # noqa: C901
|
|||
|
||||
# Check if the integration has a custom config validator
|
||||
config_validator = None
|
||||
try:
|
||||
config_validator = await integration.async_get_platform("config")
|
||||
except ImportError as err:
|
||||
# Filter out import error of the config platform.
|
||||
# If the config platform contains bad imports, make sure
|
||||
# that still fails.
|
||||
if err.name != f"{integration.pkg_path}.config":
|
||||
exc_info = ConfigExceptionInfo(
|
||||
err,
|
||||
ConfigErrorTranslationKey.CONFIG_PLATFORM_IMPORT_ERR,
|
||||
domain,
|
||||
config,
|
||||
integration_docs,
|
||||
)
|
||||
config_exceptions.append(exc_info)
|
||||
return IntegrationConfigInfo(None, config_exceptions)
|
||||
if integration.platform_exists("config") is not False:
|
||||
# If the config platform cannot possibly exist, don't try to load it.
|
||||
try:
|
||||
config_validator = await integration.async_get_platform("config")
|
||||
except ImportError as err:
|
||||
# Filter out import error of the config platform.
|
||||
# If the config platform contains bad imports, make sure
|
||||
# that still fails.
|
||||
if err.name != f"{integration.pkg_path}.config":
|
||||
exc_info = ConfigExceptionInfo(
|
||||
err,
|
||||
ConfigErrorTranslationKey.CONFIG_PLATFORM_IMPORT_ERR,
|
||||
domain,
|
||||
config,
|
||||
integration_docs,
|
||||
)
|
||||
config_exceptions.append(exc_info)
|
||||
return IntegrationConfigInfo(None, config_exceptions)
|
||||
|
||||
if config_validator is not None and hasattr(
|
||||
config_validator, "async_validate_config"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue