Relax type annotation for DataUpdateCoordinator data (#49827)
parent
a0bf95d4b5
commit
5008c27e7a
|
@ -52,7 +52,12 @@ class DataUpdateCoordinator(Generic[T]):
|
|||
self.update_method = update_method
|
||||
self.update_interval = update_interval
|
||||
|
||||
self.data: T | None = None
|
||||
# It's None before the first successful update.
|
||||
# Components should call async_config_entry_first_refresh
|
||||
# to make sure the first update was successful.
|
||||
# Set type to just T to remove annoying checks that data is not None
|
||||
# when it was already checked during setup.
|
||||
self.data: T = None # type: ignore[assignment]
|
||||
|
||||
self._listeners: list[CALLBACK_TYPE] = []
|
||||
self._job = HassJob(self._handle_refresh_interval)
|
||||
|
@ -133,7 +138,7 @@ class DataUpdateCoordinator(Generic[T]):
|
|||
"""
|
||||
await self._debounced_refresh.async_call()
|
||||
|
||||
async def _async_update_data(self) -> T | None:
|
||||
async def _async_update_data(self) -> T:
|
||||
"""Fetch the latest data from the source."""
|
||||
if self.update_method is None:
|
||||
raise NotImplementedError("Update method not implemented")
|
||||
|
|
Loading…
Reference in New Issue