Use SignalType to improve typing [esphome] (#114296)

This commit is contained in:
Marc Mueller 2024-03-27 13:22:10 +01:00 committed by GitHub
parent 45da6f8f2c
commit 09ebca9630
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View file

@ -47,6 +47,7 @@ from homeassistant.core import CALLBACK_TYPE, HomeAssistant, callback
from homeassistant.helpers import entity_registry as er
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.storage import Store
from homeassistant.util.signal_type import SignalType
from .const import DOMAIN
from .dashboard import async_get_dashboard
@ -147,9 +148,9 @@ class RuntimeEntryData:
)
@property
def signal_static_info_updated(self) -> str:
def signal_static_info_updated(self) -> SignalType[list[EntityInfo]]:
"""Return the signal to listen to for updates on static info."""
return f"esphome_{self.entry_id}_on_list"
return SignalType(f"esphome_{self.entry_id}_on_list")
@callback
def async_register_static_info_callback(

View file

@ -139,7 +139,9 @@ class ESPHomeUpdateEntity(CoordinatorEntity[ESPHomeDashboard], UpdateEntity):
)
@callback
def _handle_device_update(self, static_info: EntityInfo | None = None) -> None:
def _handle_device_update(
self, static_info: list[EntityInfo] | None = None
) -> None:
"""Handle updated data from the device."""
self._update_attrs()
self.async_write_ha_state()