Improve generic event typing [cloud] (#114728)

This commit is contained in:
Marc Mueller 2024-04-06 13:59:12 +02:00 committed by GitHub
parent 082af6e0ae
commit d24cf9e4ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 9 deletions

View File

@ -517,7 +517,9 @@ class CloudAlexaConfig(alexa_config.AbstractConfig):
return False return False
return True return True
async def _handle_entity_registry_updated(self, event: Event) -> None: async def _handle_entity_registry_updated(
self, event: Event[er.EventEntityRegistryUpdatedData]
) -> None:
"""Handle when entity registry updated.""" """Handle when entity registry updated."""
if not self.enabled or not self._cloud.is_logged_in: if not self.enabled or not self._cloud.is_logged_in:
return return
@ -527,15 +529,14 @@ class CloudAlexaConfig(alexa_config.AbstractConfig):
if not self.should_expose(entity_id): if not self.should_expose(entity_id):
return return
action = event.data["action"] to_update: list[str] = []
to_update = [] to_remove: list[str] = []
to_remove = []
if action == "create": if event.data["action"] == "create":
to_update.append(entity_id) to_update.append(entity_id)
elif action == "remove": elif event.data["action"] == "remove":
to_remove.append(entity_id) to_remove.append(entity_id)
elif action == "update" and bool( elif event.data["action"] == "update" and bool(
set(event.data["changes"]) & er.ENTITY_DESCRIBING_ATTRIBUTES set(event.data["changes"]) & er.ENTITY_DESCRIBING_ATTRIBUTES
): ):
to_update.append(entity_id) to_update.append(entity_id)

View File

@ -453,7 +453,9 @@ class CloudGoogleConfig(AbstractConfig):
self.async_schedule_google_sync_all() self.async_schedule_google_sync_all()
@callback @callback
def _handle_entity_registry_updated(self, event: Event) -> None: def _handle_entity_registry_updated(
self, event: Event[er.EventEntityRegistryUpdatedData]
) -> None:
"""Handle when entity registry updated.""" """Handle when entity registry updated."""
if ( if (
not self.enabled not self.enabled
@ -476,7 +478,9 @@ class CloudGoogleConfig(AbstractConfig):
self.async_schedule_google_sync_all() self.async_schedule_google_sync_all()
@callback @callback
async def _handle_device_registry_updated(self, event: Event) -> None: async def _handle_device_registry_updated(
self, event: Event[dr.EventDeviceRegistryUpdatedData]
) -> None:
"""Handle when device registry updated.""" """Handle when device registry updated."""
if ( if (
not self.enabled not self.enabled