Skip to content

Commit 223fbc5

Browse files
committed
🦎 q7: narrow decoded command response type
1 parent 6f9251f commit 223fbc5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

roborock/devices/rpc/b01_q7_channel.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import json
77
import logging
88
from collections.abc import Callable
9-
from typing import Any, TypeVar
9+
from typing import TypeAlias, TypeVar
1010

1111
from roborock.devices.transport.mqtt_channel import MqttChannel
1212
from roborock.exceptions import RoborockException
@@ -16,6 +16,7 @@
1616
_LOGGER = logging.getLogger(__name__)
1717
_TIMEOUT = 10.0
1818
_T = TypeVar("_T")
19+
DecodedB01Response: TypeAlias = dict[str, object] | str
1920

2021

2122
def _matches_map_response(response_message: RoborockMessage, *, version: bytes | None) -> bytes | None:
@@ -61,11 +62,11 @@ def on_message(response_message: RoborockMessage) -> None:
6162
async def send_decoded_command(
6263
mqtt_channel: MqttChannel,
6364
request_message: Q7RequestMessage,
64-
) -> Any:
65+
) -> DecodedB01Response:
6566
"""Send a command on the MQTT channel and get a decoded response."""
6667
_LOGGER.debug("Sending B01 MQTT command: %s", request_message)
6768

68-
def find_response(response_message: RoborockMessage) -> Any | None:
69+
def find_response(response_message: RoborockMessage) -> DecodedB01Response | None:
6970
"""Handle incoming messages and resolve the future."""
7071
try:
7172
decoded_dps = decode_rpc_response(response_message)

0 commit comments

Comments
 (0)