Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions aioesphomeapi/_frame_helper/noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,13 @@ def _decode_noise_psk(self) -> bytes:
server_mac = self._server_mac
try:
psk_bytes = binascii.a2b_base64(psk)
except ValueError:
except ValueError as err:
raise InvalidEncryptionKeyAPIError(
f"{self._log_name}: Malformed PSK (length={len(psk)}), "
"expected base64-encoded 32-byte value",
server_name,
server_mac,
)
) from err
Comment on lines 257 to +265
if len(psk_bytes) != 32:
raise InvalidEncryptionKeyAPIError(
f"{self._log_name}: Malformed PSK (length={len(psk)}), "
Expand Down
2 changes: 1 addition & 1 deletion aioesphomeapi/host_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ async def _async_resolve_host_getaddrinfo(host: str, port: int) -> list[AddrInfo
)
except OSError as err:
_LOGGER.debug("Failed to resolve %s via getaddrinfo: %s", host, err)
raise ResolveAPIError(f"Error resolving {host} to IP address: {err}")
raise ResolveAPIError(f"Error resolving {host} to IP address: {err}") from err

_LOGGER.debug("Successfully resolved %s via getaddrinfo", host)

Expand Down
2 changes: 1 addition & 1 deletion bench/raw_ble_plain_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
b"00002f6f72672f626c75657a2f686369302f6465"
),
)
for i in range(5):
for _ in range(5):
adv.advertisements.append(fake_adv)

type_ = 93
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ exclude = [
[tool.ruff.lint]
select = [
"ASYNC", # async rules
"B", # flake8-bugbear
"E", # pycodestyle
"F", # pyflakes/autoflake
"FLY", # flynt
Expand Down
2 changes: 1 addition & 1 deletion tests/benchmarks/test_bluetooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async def test_raw_ble_plain_text(benchmark: BenchmarkFixture) -> None:
b"00002f6f72672f626c75657a2f686369302f6465"
),
)
for i in range(5):
for _ in range(5):
adv.advertisements.append(fake_adv)

type_ = 93
Expand Down
2 changes: 1 addition & 1 deletion tests/test__frame_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ async def test_plaintext_frame_helper_multiple_payloads_single_packet(
# Make sure we correctly handle multiple payloads in a single packet
mock_data_received(helper, in_bytes * 5)

for i in range(5):
for _ in range(5):
pkt = packets.pop()
type_, data = pkt

Expand Down
2 changes: 1 addition & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

def test_order_and_no_missing_numbers_in_message_type_to_proto():
"""Test that MESSAGE_TYPE_TO_PROTO has no missing numbers."""
for idx, (k, v) in enumerate(MESSAGE_TYPE_TO_PROTO.items()):
for idx, k in enumerate(MESSAGE_TYPE_TO_PROTO):
assert idx + 1 == k


Expand Down
2 changes: 1 addition & 1 deletion tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ async def test_bluetooth_gatt_services_from_dict() -> None:
)
],
)
services == BluetoothGATTServicesModel.from_dict(
services = BluetoothGATTServicesModel.from_dict(
{
"services": [
{
Expand Down
4 changes: 2 additions & 2 deletions tests/test_reconnect_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,8 @@ async def resolve_host_waiting_for_zeroconf(*args, **kwargs):
# This simulates the resolver waiting for mDNS records
try:
await asyncio.wait_for(resolve_event.wait(), timeout=0.1)
except TimeoutError:
raise APIConnectionError("Resolution timed out")
except TimeoutError as err:
raise APIConnectionError("Resolution timed out") from err
else:
return # Resolution succeeded

Expand Down
Loading