Simplify load_executor check in loader (#112029)

This commit is contained in:
J. Nick Koston 2024-03-02 09:01:11 -10:00 committed by GitHub
parent 14b737e9b8
commit 567d4d5926
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -844,13 +844,11 @@ class Integration:
if debug := _LOGGER.isEnabledFor(logging.DEBUG):
start = time.perf_counter()
domain = self.domain
load_executor = (
self.import_executor
and f"hass.components.{domain}" not in sys.modules
and f"custom_components.{domain}" not in sys.modules
)
# Some integrations fail on import because they call functions incorrectly.
# So we do it before validating config to catch these errors.
load_executor = (
self.import_executor and f"{self.pkg_path}.{domain}" not in sys.modules
)
if load_executor:
try:
comp = await self.hass.async_add_import_executor_job(self.get_component)
@ -918,8 +916,7 @@ class Integration:
load_executor = (
self.import_executor
and domain not in self.hass.config.components
and f"hass.components.{domain}" not in sys.modules
and f"custom_components.{domain}" not in sys.modules
and f"{self.pkg_path}.{domain}" not in sys.modules
)
try:
if load_executor: