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 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."""
if not self.enabled or not self._cloud.is_logged_in:
return
@ -527,15 +529,14 @@ class CloudAlexaConfig(alexa_config.AbstractConfig):
if not self.should_expose(entity_id):
return
action = event.data["action"]
to_update = []
to_remove = []
to_update: list[str] = []
to_remove: list[str] = []
if action == "create":
if event.data["action"] == "create":
to_update.append(entity_id)
elif action == "remove":
elif event.data["action"] == "remove":
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
):
to_update.append(entity_id)

View File

@ -453,7 +453,9 @@ class CloudGoogleConfig(AbstractConfig):
self.async_schedule_google_sync_all()
@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."""
if (
not self.enabled
@ -476,7 +478,9 @@ class CloudGoogleConfig(AbstractConfig):
self.async_schedule_google_sync_all()
@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."""
if (
not self.enabled