Skip to content

Commit

Permalink
chore: ruff RET505 (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
rokam authored Jun 15, 2024
1 parent e2189a9 commit bdd769c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
3 changes: 1 addition & 2 deletions midealocal/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,7 @@ def get_id_from_response(response: bytearray) -> int:
assert child
m = child.attrib
return int.from_bytes(bytearray.fromhex(m["devId"]), "little")
else:
return 0
return 0


def bytes2port(paramArrayOfbyte: bytes | None) -> int:
Expand Down
22 changes: 11 additions & 11 deletions midealocal/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,14 @@ def aes_decrypt(
len(aes_key),
).decode(),
)
else: # CBC
return cast(
str,
unpad(
AES.new(aes_key, AES.MODE_CBC, iv=aes_iv).decrypt(data),
len(aes_key),
).decode(),
)
# CBC
return cast(
str,
unpad(
AES.new(aes_key, AES.MODE_CBC, iv=aes_iv).decrypt(data),
len(aes_key),
).decode(),
)


class MeijuCloudSecurity(CloudSecurity):
Expand Down Expand Up @@ -351,11 +351,11 @@ def decode_8370(self, data: bytes) -> tuple[list, bytes]:
raise MessageWrongFormat("not an 8370 message")
size = int.from_bytes(header[2:4], "big") + 8
leftover = None
if len(data) < size:
return [], data
elif len(data) > size:
if len(data) > size:
leftover = data[size:]
data = data[:size]
elif len(data) < size:
return [], data
if header[4] != HEADER_8370_4TH_BYTE:
raise MessageWrongFormat("missing byte 4")
padding = header[5] >> 4
Expand Down

0 comments on commit bdd769c

Please sign in to comment.