Improve august typing (3) (#108329)

This commit is contained in:
Marc Mueller 2024-01-19 00:14:49 +01:00 committed by GitHub
parent 6e8d491dae
commit 6e8e14fbe2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 10 additions and 10 deletions

View file

@ -140,7 +140,7 @@ class AugustData(AugustSubscriberMixin):
self._config_entry = config_entry
self._hass = hass
self._august_gateway = august_gateway
self.activity_stream: ActivityStream | None = None
self.activity_stream: ActivityStream = None # type: ignore[assignment]
self._api = august_gateway.api
self._device_detail_by_id: dict[str, LockDetail | DoorbellDetail] = {}
self._doorbells_by_id: dict[str, Doorbell] = {}
@ -153,7 +153,7 @@ class AugustData(AugustSubscriberMixin):
"""Brand of the device."""
return self._config_entry.data.get(CONF_BRAND, DEFAULT_BRAND)
async def async_setup(self):
async def async_setup(self) -> None:
"""Async setup of august device data and activities."""
token = self._august_gateway.access_token
# This used to be a gather but it was less reliable with august's recent api changes.
@ -248,16 +248,16 @@ class AugustData(AugustSubscriberMixin):
device = self.get_device_detail(device_id)
activities = activities_from_pubnub_message(device, date_time, message)
activity_stream = self.activity_stream
assert activity_stream is not None
if activities:
activity_stream.async_process_newer_device_activities(activities)
self.async_signal_device_id_update(device.device_id)
activity_stream.async_schedule_house_id_refresh(device.house_id)
@callback
def async_stop(self):
def async_stop(self) -> None:
"""Stop the subscriptions."""
self._pubnub_unsub()
if self._pubnub_unsub:
self._pubnub_unsub()
self.activity_stream.async_stop()
@property
@ -303,7 +303,7 @@ class AugustData(AugustSubscriberMixin):
exc_info=err,
)
async def _async_refresh_device_detail_by_id(self, device_id):
async def _async_refresh_device_detail_by_id(self, device_id: str) -> None:
if device_id in self._locks_by_id:
if self.activity_stream and self.activity_stream.pubnub.connected:
saved_attrs = _save_live_attrs(self._device_detail_by_id[device_id])

View file

@ -63,7 +63,7 @@ class AugustCamera(AugustEntityMixin, Camera):
return self._detail.model
@callback
def _update_from_data(self):
def _update_from_data(self) -> None:
"""Get the latest state of the sensor."""
doorbell_activity = self._data.activity_stream.get_latest_device_activity(
self._device_id,

View file

@ -63,7 +63,7 @@ class AugustEntityMixin(Entity):
def _update_from_data(self) -> None:
"""Update the entity state from the data object."""
async def async_added_to_hass(self):
async def async_added_to_hass(self) -> None:
"""Subscribe to updates."""
self.async_on_remove(
self._data.async_subscribe_device_id(

View file

@ -91,7 +91,7 @@ class AugustLock(AugustEntityMixin, RestoreEntity, LockEntity):
return False
@callback
def _update_from_data(self):
def _update_from_data(self) -> None:
"""Get the latest state of the sensor and update activity."""
activity_stream = self._data.activity_stream
device_id = self._device_id

View file

@ -194,7 +194,7 @@ class AugustOperatorSensor(AugustEntityMixin, RestoreSensor):
self._update_from_data()
@callback
def _update_from_data(self):
def _update_from_data(self) -> None:
"""Get the latest state of the sensor and update activity."""
lock_activity = self._data.activity_stream.get_latest_device_activity(
self._device_id, {ActivityType.LOCK_OPERATION}