Relax type annotation for DataUpdateCoordinator data (#49827)

This commit is contained in:
Ruslan Sayfutdinov 2021-04-29 05:31:08 +01:00 committed by GitHub
parent a0bf95d4b5
commit 5008c27e7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -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")