diff --git a/homeassistant/helpers/update_coordinator.py b/homeassistant/helpers/update_coordinator.py index f9b97698220..09844640ce7 100644 --- a/homeassistant/helpers/update_coordinator.py +++ b/homeassistant/helpers/update_coordinator.py @@ -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")