Skip to content

Commit 6dd21f6

Browse files
author
NOisi-X
committed
refactor: streamline function definitions and remove unnecessary line breaks
1 parent 2f9d661 commit 6dd21f6

4 files changed

Lines changed: 5 additions & 19 deletions

File tree

roborock/devices/traits/a01/__init__.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,7 @@ async def _get_current_params(self) -> ZeoStartParams:
280280
)
281281
for dp in self._START_PARAM_DPS:
282282
if dp not in current:
283-
raise RoborockException(
284-
f"Device did not return required DP {dp.name} ({int(dp)})"
285-
)
283+
raise RoborockException(f"Device did not return required DP {dp.name} ({int(dp)})")
286284
return ZeoStartParams(
287285
mode=current[RoborockZeoProtocol.MODE],
288286
program=current[RoborockZeoProtocol.PROGRAM],
@@ -314,9 +312,7 @@ async def start(self) -> dict[RoborockZeoProtocol, Any]:
314312
):
315313
if val is not None:
316314
dps[dp] = val
317-
return await send_decoded_command(
318-
self._channel, dps, value_encoder=lambda x: x, qos=MqttQos.AT_LEAST_ONCE
319-
)
315+
return await send_decoded_command(self._channel, dps, value_encoder=lambda x: x, qos=MqttQos.AT_LEAST_ONCE)
320316

321317
async def set_value(self, protocol: RoborockZeoProtocol, value: Any) -> dict[RoborockZeoProtocol, Any]:
322318
"""Set a value for a specific protocol on the device."""

roborock/mqtt/roborock_session.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,7 @@ def delayed_unsub():
361361

362362
return delayed_unsub
363363

364-
async def publish(
365-
self, topic: str, message: bytes, qos: MqttQos = MqttQos.AT_MOST_ONCE
366-
) -> None:
364+
async def publish(self, topic: str, message: bytes, qos: MqttQos = MqttQos.AT_MOST_ONCE) -> None:
367365
"""Publish a message on the topic.
368366
369367
Args:
@@ -425,9 +423,7 @@ async def subscribe(self, device_id: str, callback: Callable[[bytes], None]) ->
425423
await self._maybe_start()
426424
return await self._session.subscribe(device_id, callback)
427425

428-
async def publish(
429-
self, topic: str, message: bytes, qos: MqttQos = MqttQos.AT_MOST_ONCE
430-
) -> None:
426+
async def publish(self, topic: str, message: bytes, qos: MqttQos = MqttQos.AT_MOST_ONCE) -> None:
431427
"""Publish a message on the specified topic.
432428
433429
This will raise an exception if the message could not be sent.

roborock/mqtt/session.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class MqttQos(IntEnum):
2828
EXACTLY_ONCE = 2
2929
"""Guaranteed delivery with no duplicates. Broker sends PUBREC/PUBREL/PUBCOMP."""
3030

31+
3132
SessionUnauthorizedHook = Callable[[], None]
3233

3334

roborock/testing/channel.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ def __init__(self, is_local: bool = False):
8383
self.close = MagicMock(side_effect=self._close)
8484

8585
self.protocol_version = LocalProtocolVersion.V1
86-
self.publish_handler: Callable[[RoborockMessage], None] | None = self._default_publish_handler
8786

8887
self.restart = AsyncMock()
8988
self.health_manager = HealthManager(self.restart)
@@ -141,12 +140,6 @@ def notify_subscribers(self, message: RoborockMessage) -> None:
141140
for subscriber in list(self.subscribers):
142141
subscriber(message)
143142

144-
async def _default_publish_handler(self, message: RoborockMessage) -> None:
145-
"""Default handler that pops canned responses from response_queue."""
146-
if self.response_queue:
147-
response = self.response_queue.pop(0)
148-
self.notify_subscribers(response)
149-
150143
def inject_error(self, exception: Exception) -> None:
151144
"""Inject a transient failure into all channel operations (publish, subscribe, connect)."""
152145
self.publish.side_effect = exception

0 commit comments

Comments
 (0)