Migrate remaining get_platform in check_config to async_get_platform (#112470)
These were very likely to be cached so they were low on the list to migrate, but since they are called in the event loop its best to be sure we do no blocking I/O
This commit is contained in:
parent
0f69a0647c
commit
8fe80a4766
2 changed files with 4 additions and 4 deletions
|
@ -199,7 +199,7 @@ async def async_check_ha_config_file( # noqa: C901
|
||||||
# Check if the integration has a custom config validator
|
# Check if the integration has a custom config validator
|
||||||
config_validator = None
|
config_validator = None
|
||||||
try:
|
try:
|
||||||
config_validator = integration.get_platform("config")
|
config_validator = await integration.async_get_platform("config")
|
||||||
except ImportError as err:
|
except ImportError as err:
|
||||||
# Filter out import error of the config platform.
|
# Filter out import error of the config platform.
|
||||||
# If the config platform contains bad imports, make sure
|
# If the config platform contains bad imports, make sure
|
||||||
|
@ -270,7 +270,7 @@ async def async_check_ha_config_file( # noqa: C901
|
||||||
p_integration = await async_get_integration_with_requirements(
|
p_integration = await async_get_integration_with_requirements(
|
||||||
hass, p_name
|
hass, p_name
|
||||||
)
|
)
|
||||||
platform = p_integration.get_platform(domain)
|
platform = await p_integration.async_get_platform(domain)
|
||||||
except loader.IntegrationNotFound as ex:
|
except loader.IntegrationNotFound as ex:
|
||||||
# We get this error if an integration is not found. In recovery mode and
|
# We get this error if an integration is not found. In recovery mode and
|
||||||
# safe mode, this currently happens for all custom integrations. Don't
|
# safe mode, this currently happens for all custom integrations. Don't
|
||||||
|
|
|
@ -338,7 +338,7 @@ async def test_config_platform_import_error(hass: HomeAssistant) -> None:
|
||||||
# Make sure they don't exist
|
# Make sure they don't exist
|
||||||
files = {YAML_CONFIG_FILE: BASE_CONFIG + "light:\n platform: beer"}
|
files = {YAML_CONFIG_FILE: BASE_CONFIG + "light:\n platform: beer"}
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.loader.Integration.get_platform",
|
"homeassistant.loader.Integration.async_get_platform",
|
||||||
side_effect=ImportError("blablabla"),
|
side_effect=ImportError("blablabla"),
|
||||||
), patch("os.path.isfile", return_value=True), patch_yaml_files(files):
|
), patch("os.path.isfile", return_value=True), patch_yaml_files(files):
|
||||||
res = await async_check_ha_config_file(hass)
|
res = await async_check_ha_config_file(hass)
|
||||||
|
@ -358,7 +358,7 @@ async def test_platform_import_error(hass: HomeAssistant) -> None:
|
||||||
# Make sure they don't exist
|
# Make sure they don't exist
|
||||||
files = {YAML_CONFIG_FILE: BASE_CONFIG + "light:\n platform: demo"}
|
files = {YAML_CONFIG_FILE: BASE_CONFIG + "light:\n platform: demo"}
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.loader.Integration.get_platform",
|
"homeassistant.loader.Integration.async_get_platform",
|
||||||
side_effect=[None, ImportError("blablabla")],
|
side_effect=[None, ImportError("blablabla")],
|
||||||
), patch("os.path.isfile", return_value=True), patch_yaml_files(files):
|
), patch("os.path.isfile", return_value=True), patch_yaml_files(files):
|
||||||
res = await async_check_ha_config_file(hass)
|
res = await async_check_ha_config_file(hass)
|
||||||
|
|
Loading…
Add table
Reference in a new issue