Skip to content

Commit 197694e

Browse files
sfo2001claude
andcommitted
fix: resolve test assertion and improve code formatting
- Fix test assertion for encode_pdo_value_unsupported_type to match new error format - Apply black and isort formatting fixes for code consistency - Maintain 10.00/10 pylint score 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1e76214 commit 197694e

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

aiocomfoconnect/bridge.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555

5656
class SelfDeregistrationError(Exception):
5757
"""Exception raised when trying to deregister self."""
58-
pass
5958

6059

6160
class EventBus:
@@ -166,11 +165,9 @@ async def _connect(self, uuid: str) -> asyncio.Task:
166165
"""
167166
_LOGGER.debug("Connecting to bridge %s", self.host)
168167
try:
169-
self._reader, self._writer = await asyncio.wait_for(
170-
asyncio.open_connection(self.host, self.PORT), TIMEOUT
171-
)
168+
self._reader, self._writer = await asyncio.wait_for(asyncio.open_connection(self.host, self.PORT), TIMEOUT)
172169
except asyncio.TimeoutError as exc:
173-
_LOGGER.warning(f"Timeout while connecting to bridge {self.host}")
170+
_LOGGER.warning("Timeout while connecting to bridge %s", self.host)
174171
raise AioComfoConnectTimeout("Timeout while connecting to bridge") from exc
175172

176173
self._reference = 1
@@ -421,7 +418,7 @@ async def _process_message(self) -> None:
421418
if exc.message.cmd.reference:
422419
self._event_bus.emit(exc.message.cmd.reference, exc)
423420
except DecodeError as exc:
424-
_LOGGER.error(f"Failed to decode message: {exc}")
421+
_LOGGER.error("Failed to decode message: %s", exc)
425422

426423
@log_call
427424
def cmd_start_session(self, take_over: bool = False) -> Awaitable[Message]:

aiocomfoconnect/util.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@
77

88
from __future__ import annotations
99

10-
from aiocomfoconnect.const import PdoType, CAN_ID_OFFSET, PDO_SHIFT, UINT64_BITS, CONSTRAINT_BITS
10+
from aiocomfoconnect.const import (
11+
CAN_ID_OFFSET,
12+
CONSTRAINT_BITS,
13+
PDO_SHIFT,
14+
UINT64_BITS,
15+
PdoType,
16+
)
1117

1218

1319
def bytestring(arr: list[int | bytes]) -> bytes:
1420
"""Join an array of bytes/integers into a bytestring. Unlike `bytes()`, this method supports a mixed array with integers and bytes.
15-
21+
1622
Args:
1723
arr (list[int | bytes]): List of integers or bytes.
1824

tests/test_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ def test_encode_pdo_value_unsupported_type(self):
434434
encode_pdo_value(123, PdoType.TYPE_CN_STRING)
435435

436436
assert "Type is not supported at this time" in str(exc_info.value)
437-
assert PdoType.TYPE_CN_STRING in exc_info.value.args
437+
assert "9" in str(exc_info.value)
438438

439439
def test_encode_pdo_value_little_endian(self):
440440
"""Test encode_pdo_value uses little endian byte order."""

0 commit comments

Comments
 (0)