Skip to content

Commit

Permalink
Fix mypy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
natekspencer committed Oct 11, 2024
1 parent e73c6ae commit 3fea32e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
4 changes: 3 additions & 1 deletion vivintpy/devices/door_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."""
Expand Down
2 changes: 1 addition & 1 deletion vivintpy/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions vivintpy/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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."""
Expand Down

0 comments on commit 3fea32e

Please sign in to comment.