Enable ruff check for ANN (#1139)

This commit is contained in:
Teemu R.
2024-11-10 19:55:13 +01:00
committed by GitHub
parent 6b44fe6242
commit 66eb17057e
89 changed files with 596 additions and 452 deletions

View File

@@ -12,12 +12,12 @@ class Experimental:
ENV_VAR = "KASA_EXPERIMENTAL"
@classmethod
def set_enabled(cls, enabled):
def set_enabled(cls, enabled: bool) -> None:
"""Set the enabled value."""
cls._enabled = enabled
@classmethod
def enabled(cls):
def enabled(cls) -> bool:
"""Get the enabled value."""
if cls._enabled is not None:
return cls._enabled

View File

@@ -50,11 +50,13 @@ class SmartCameraProtocol(SmartProtocol):
"""Class for SmartCamera Protocol."""
async def _handle_response_lists(
self, response_result: dict[str, Any], method, retry_count
):
self, response_result: dict[str, Any], method: str, retry_count: int
) -> None:
pass
def _handle_response_error_code(self, resp_dict: dict, method, raise_on_error=True):
def _handle_response_error_code(
self, resp_dict: dict, method: str, raise_on_error: bool = True
) -> None:
error_code_raw = resp_dict.get("error_code")
try:
error_code = SmartErrorCode.from_int(error_code_raw)
@@ -203,7 +205,7 @@ class _ChildCameraProtocolWrapper(SmartProtocol):
device responses before returning to the caller.
"""
def __init__(self, device_id: str, base_protocol: SmartProtocol):
def __init__(self, device_id: str, base_protocol: SmartProtocol) -> None:
self._device_id = device_id
self._protocol = base_protocol
self._transport = base_protocol._transport

View File

@@ -256,7 +256,9 @@ class SslAesTransport(BaseTransport):
return ret_val # type: ignore[return-value]
@staticmethod
def generate_confirm_hash(local_nonce, server_nonce, pwd_hash):
def generate_confirm_hash(
local_nonce: str, server_nonce: str, pwd_hash: str
) -> str:
"""Generate an auth hash for the protocol on the supplied credentials."""
expected_confirm_bytes = _sha256_hash(
local_nonce.encode() + pwd_hash.encode() + server_nonce.encode()
@@ -264,7 +266,9 @@ class SslAesTransport(BaseTransport):
return expected_confirm_bytes + server_nonce + local_nonce
@staticmethod
def generate_digest_password(local_nonce, server_nonce, pwd_hash):
def generate_digest_password(
local_nonce: str, server_nonce: str, pwd_hash: str
) -> str:
"""Generate an auth hash for the protocol on the supplied credentials."""
digest_password_hash = _sha256_hash(
pwd_hash.encode() + local_nonce.encode() + server_nonce.encode()
@@ -275,7 +279,7 @@ class SslAesTransport(BaseTransport):
@staticmethod
def generate_encryption_token(
token_type, local_nonce, server_nonce, pwd_hash
token_type: str, local_nonce: str, server_nonce: str, pwd_hash: str
) -> bytes:
"""Generate encryption token."""
hashedKey = _sha256_hash(
@@ -302,7 +306,9 @@ class SslAesTransport(BaseTransport):
local_nonce, server_nonce, pwd_hash = await self.perform_handshake1()
await self.perform_handshake2(local_nonce, server_nonce, pwd_hash)
async def perform_handshake2(self, local_nonce, server_nonce, pwd_hash) -> None:
async def perform_handshake2(
self, local_nonce: str, server_nonce: str, pwd_hash: str
) -> None:
"""Perform the handshake."""
_LOGGER.debug("Performing handshake2 ...")
digest_password = self.generate_digest_password(