Remove unnecessary TYPE_CHECKING
declarations in SimpliSafe (#65750)
This commit is contained in:
parent
3387e8368b
commit
fbe4d42729
4 changed files with 16 additions and 26 deletions
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||
import asyncio
|
||||
from collections.abc import Callable, Iterable
|
||||
from datetime import timedelta
|
||||
from typing import TYPE_CHECKING, Any, cast
|
||||
from typing import Any, cast
|
||||
|
||||
from simplipy import API
|
||||
from simplipy.device import Device, DeviceTypes
|
||||
|
@ -235,8 +235,7 @@ def _async_get_system_for_service_call(
|
|||
) is None:
|
||||
raise vol.Invalid("Invalid device ID specified")
|
||||
|
||||
if TYPE_CHECKING:
|
||||
assert alarm_control_panel_device_entry.via_device_id
|
||||
assert alarm_control_panel_device_entry.via_device_id
|
||||
|
||||
if (
|
||||
base_station_device_entry := device_registry.async_get(
|
||||
|
@ -494,8 +493,7 @@ class SimpliSafe:
|
|||
|
||||
async def _async_start_websocket_loop(self) -> None:
|
||||
"""Start a websocket reconnection loop."""
|
||||
if TYPE_CHECKING:
|
||||
assert self._api.websocket
|
||||
assert self._api.websocket
|
||||
|
||||
should_reconnect = True
|
||||
|
||||
|
@ -527,8 +525,7 @@ class SimpliSafe:
|
|||
LOGGER.debug("Websocket reconnection task successfully canceled")
|
||||
self._websocket_reconnect_task = None
|
||||
|
||||
if TYPE_CHECKING:
|
||||
assert self._api.websocket
|
||||
assert self._api.websocket
|
||||
await self._api.websocket.async_disconnect()
|
||||
|
||||
@callback
|
||||
|
@ -565,9 +562,8 @@ class SimpliSafe:
|
|||
|
||||
async def async_init(self) -> None:
|
||||
"""Initialize the SimpliSafe "manager" class."""
|
||||
if TYPE_CHECKING:
|
||||
assert self._api.refresh_token
|
||||
assert self._api.websocket
|
||||
assert self._api.refresh_token
|
||||
assert self._api.websocket
|
||||
|
||||
self._api.websocket.add_event_callback(self._async_websocket_on_event)
|
||||
self._websocket_reconnect_task = asyncio.create_task(
|
||||
|
@ -576,9 +572,7 @@ class SimpliSafe:
|
|||
|
||||
async def async_websocket_disconnect_listener(_: Event) -> None:
|
||||
"""Define an event handler to disconnect from the websocket."""
|
||||
if TYPE_CHECKING:
|
||||
assert self._api.websocket
|
||||
|
||||
assert self._api.websocket
|
||||
await self._async_cancel_websocket_loop()
|
||||
|
||||
self.entry.async_on_unload(
|
||||
|
@ -625,10 +619,8 @@ class SimpliSafe:
|
|||
"""Handle a new refresh token."""
|
||||
async_save_refresh_token(token)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
assert self._api.websocket
|
||||
|
||||
# Open a new websocket connection with the fresh token:
|
||||
assert self._api.websocket
|
||||
await self._async_cancel_websocket_loop()
|
||||
self._websocket_reconnect_task = self._hass.async_create_task(
|
||||
self._async_start_websocket_loop()
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
"""Support for SimpliSafe alarm control panels."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from simplipy.errors import SimplipyError
|
||||
from simplipy.system import SystemStates
|
||||
from simplipy.system.v3 import SystemV3
|
||||
|
@ -240,8 +238,9 @@ class SimpliSafeAlarm(SimpliSafeEntity, AlarmControlPanelEntity):
|
|||
def async_update_from_websocket_event(self, event: WebsocketEvent) -> None:
|
||||
"""Update the entity when new data comes from the websocket."""
|
||||
self._attr_changed_by = event.changed_by
|
||||
if TYPE_CHECKING:
|
||||
assert event.event_type
|
||||
|
||||
assert event.event_type
|
||||
|
||||
if state := STATE_MAP_FROM_WEBSOCKET_EVENT.get(event.event_type):
|
||||
self._attr_state = state
|
||||
self.async_reset_error_count()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Config flow to configure the SimpliSafe component."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, NamedTuple
|
||||
from typing import Any, NamedTuple
|
||||
|
||||
from simplipy import API
|
||||
from simplipy.errors import InvalidCredentialsError, SimplipyError
|
||||
|
@ -97,8 +97,7 @@ class SimpliSafeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
if user_input is None:
|
||||
return self._async_show_form()
|
||||
|
||||
if TYPE_CHECKING:
|
||||
assert self._oauth_values
|
||||
assert self._oauth_values
|
||||
|
||||
errors = {}
|
||||
session = aiohttp_client.async_get_clientsession(self.hass)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Support for SimpliSafe locks."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any
|
||||
from typing import Any
|
||||
|
||||
from simplipy.device.lock import Lock, LockStates
|
||||
from simplipy.errors import SimplipyError
|
||||
|
@ -100,8 +100,8 @@ class SimpliSafeLock(SimpliSafeEntity, LockEntity):
|
|||
@callback
|
||||
def async_update_from_websocket_event(self, event: WebsocketEvent) -> None:
|
||||
"""Update the entity when new data comes from the websocket."""
|
||||
if TYPE_CHECKING:
|
||||
assert event.event_type
|
||||
assert event.event_type
|
||||
|
||||
if state := STATE_MAP_FROM_WEBSOCKET_EVENT.get(event.event_type) is not None:
|
||||
self._attr_is_locked = state
|
||||
self.async_reset_error_count()
|
||||
|
|
Loading…
Add table
Reference in a new issue