1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Add ComponentProtocol to improve type checking (#90586)

This commit is contained in:
epenet
2023-03-31 20:19:58 +02:00
committed by GitHub
parent 03137feba5
commit 611d4135fd
5 changed files with 77 additions and 17 deletions

View File

@@ -383,7 +383,7 @@ class ConfigEntry:
result = await component.async_setup_entry(hass, self)
if not isinstance(result, bool):
_LOGGER.error(
_LOGGER.error( # type: ignore[unreachable]
"%s.async_setup_entry did not return boolean", integration.domain
)
result = False
@@ -546,8 +546,7 @@ class ConfigEntry:
await self._async_process_on_unload()
# https://github.com/python/mypy/issues/11839
return result # type: ignore[no-any-return]
return result
except Exception as ex: # pylint: disable=broad-except
_LOGGER.exception(
"Error unloading entry %s for %s", self.title, integration.domain
@@ -628,15 +627,14 @@ class ConfigEntry:
try:
result = await component.async_migrate_entry(hass, self)
if not isinstance(result, bool):
_LOGGER.error(
_LOGGER.error( # type: ignore[unreachable]
"%s.async_migrate_entry did not return boolean", self.domain
)
return False
if result:
# pylint: disable-next=protected-access
hass.config_entries._async_schedule_save()
# https://github.com/python/mypy/issues/11839
return result # type: ignore[no-any-return]
return result
except Exception: # pylint: disable=broad-except
_LOGGER.exception(
"Error migrating entry %s for %s", self.title, self.domain