diff --git a/vivintpy/devices/door_lock.py b/vivintpy/devices/door_lock.py index 238a250..223ee7b 100644 --- a/vivintpy/devices/door_lock.py +++ b/vivintpy/devices/door_lock.py @@ -2,6 +2,8 @@ from __future__ import annotations +from typing import cast + from ..const import LockAttribute from ..const import ZWaveDeviceAttribute as Attribute from ..utils import send_deprecation_warning @@ -30,7 +32,7 @@ def node_online(self) -> bool: @property def user_code_list(self) -> list[int]: """Return the user code list.""" - return self.data.get(LockAttribute.USER_CODE_LIST, []) + return cast(list[int], self.data.get(LockAttribute.USER_CODE_LIST, [])) async def set_state(self, locked: bool) -> None: """Set door lock's state.""" diff --git a/vivintpy/system.py b/vivintpy/system.py index 5f943c2..d3a98ec 100644 --- a/vivintpy/system.py +++ b/vivintpy/system.py @@ -78,7 +78,7 @@ async def refresh(self) -> None: def update_user_data(self, data: list[dict]) -> None: """Update user data.""" for d in data: - user = first_or_none(self.users, lambda user, d=d: user.id == d["_id"]) + user = first_or_none(self.users, lambda user: user.id == d["_id"]) if not user: _LOGGER.debug("User not found for system %s: %s", self.id, d) return diff --git a/vivintpy/user.py b/vivintpy/user.py index d7c7a6c..7589ff4 100644 --- a/vivintpy/user.py +++ b/vivintpy/user.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, cast from .const import UserAttribute as Attribute from .entity import Entity @@ -28,22 +28,22 @@ def __repr__(self) -> str: @property def has_lock_pin(self) -> bool: """Return True if the user has pins.""" - return self.data[Attribute.HAS_LOCK_PIN] + return bool(self.data[Attribute.HAS_LOCK_PIN]) @property def has_panel_pin(self) -> bool: """Return True if the user has pins.""" - return self.data[Attribute.HAS_PANEL_PIN] + return bool(self.data[Attribute.HAS_PANEL_PIN]) @property def has_pins(self) -> bool: """Return True if the user has pins.""" - return self.data[Attribute.HAS_PINS] + return bool(self.data[Attribute.HAS_PINS]) @property def has_remote_access(self) -> bool: """Return True if the user has remote access.""" - return self.data[Attribute.REMOTE_ACCESS] + return bool(self.data[Attribute.REMOTE_ACCESS]) @property def id(self) -> int: # pylint: disable=invalid-name @@ -53,22 +53,22 @@ def id(self) -> int: # pylint: disable=invalid-name @property def is_admin(self) -> bool: """Return True if the user is an admin.""" - return self.data[Attribute.ADMIN] + return bool(self.data[Attribute.ADMIN]) @property def is_registered(self) -> bool: """Return True if the user is registered.""" - return self.data[Attribute.REGISTERED] + return bool(self.data[Attribute.REGISTERED]) @property def lock_ids(self) -> list[int]: """User's lock ids.""" - return self.data.get(Attribute.LOCK_IDS, []) + return cast(list[int], self.data.get(Attribute.LOCK_IDS, [])) @property def name(self) -> str: """User's name.""" - return self.data[Attribute.NAME] + return str(self.data[Attribute.NAME]) def handle_pubnub_message(self, message: dict) -> None: """Handle a pubnub message addressed to this user."""