Revert "Avoid pre-importing config_flows if the integration does not … (#113553)

Revert "Avoid pre-importing config_flows if the integration does not support …"

This reverts commit 9940f51b95.
This commit is contained in:
G Johansson 2024-03-15 23:15:36 +01:00 committed by GitHub
parent 77a94ea515
commit e8de1a7031
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 42 additions and 89 deletions

View file

@ -349,9 +349,6 @@ class ConfigEntry:
# Supports remove device
self.supports_remove_device: bool | None = None
# Supports migrate
self.supports_migrate: bool | None = None
# Supports options
self._supports_options: bool | None = None
@ -494,7 +491,6 @@ class ConfigEntry:
self.supports_remove_device = await support_remove_from_device(
hass, self.domain
)
try:
component = await integration.async_get_component()
except ImportError as err:
@ -510,12 +506,7 @@ class ConfigEntry:
)
return
if self.supports_migrate is None:
self.supports_migrate = hasattr(component, "async_migrate_entry")
if domain_is_integration and self.supports_migrate:
# Avoid loading the config_flow module unless we need to check
# the version to see if we need to migrate
if domain_is_integration:
try:
await integration.async_get_platforms(("config_flow",))
except ImportError as err:
@ -796,7 +787,11 @@ class ConfigEntry:
if same_major_version and self.minor_version == handler.MINOR_VERSION:
return True
if not self.supports_migrate:
if not (integration := self._integration_for_domain):
integration = await loader.async_get_integration(hass, self.domain)
component = await integration.async_get_component()
supports_migrate = hasattr(component, "async_migrate_entry")
if not supports_migrate:
if same_major_version:
return True
_LOGGER.error(
@ -806,11 +801,6 @@ class ConfigEntry:
)
return False
if not (integration := self._integration_for_domain):
integration = await loader.async_get_integration(hass, self.domain)
component = await integration.async_get_component()
try:
result = await component.async_migrate_entry(hass, self)
if not isinstance(result, bool):