Skip to content

Commit 0a0c144

Browse files
committed
fix(testing): resolve mypy type hints and ruff formatting in a01_simulator.py
1 parent 857f929 commit 0a0c144

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

roborock/testing/a01_simulator.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
"""Stateful simulator for Roborock A01 (Dyad and Zeo) devices."""
22

33
import copy
4-
from dataclasses import replace
54
import enum
65
import json
76
import logging
7+
from dataclasses import replace
88
from typing import Any
99

1010
from roborock.data import HomeDataDevice, HomeDataProduct, RoborockCategory
@@ -29,7 +29,6 @@
2929
)
3030
from roborock.exceptions import RoborockException
3131
from roborock.protocols.a01_protocol import (
32-
A01_VERSION,
3332
decode_rpc_response,
3433
encode_mqtt_payload,
3534
)
@@ -127,13 +126,11 @@ def __init__(
127126
duid: str,
128127
device_info: HomeDataDevice,
129128
product: HomeDataProduct,
130-
status: dict[int | enum.Enum, Any] | None = None,
129+
status: dict[Any, Any] | None = None,
131130
):
132131
super().__init__(duid, device_info, product, has_local_channel=False)
133132
raw_status = status or {}
134-
self.status: dict[int, Any] = {
135-
int(_extract_int_value(k)): _extract_int_value(v) for k, v in raw_status.items()
136-
}
133+
self.status: dict[int, Any] = {int(_extract_int_value(k)): _extract_int_value(v) for k, v in raw_status.items()}
137134

138135
def set_protocol_value(self, protocol: Any, value: Any, push: bool = False) -> None:
139136
"""Set a protocol value in the simulator status.
@@ -194,7 +191,7 @@ async def _handle_publish(self, message: RoborockMessage, channel: Any) -> None:
194191

195192
def push_dps(self, dps_updates: dict[int, Any]) -> None:
196193
"""Push encrypted A01 status datapoint updates to subscribers."""
197-
msg = encode_mqtt_payload(dps_updates)
194+
msg = encode_mqtt_payload(dps_updates) # type: ignore[arg-type]
198195
self.mqtt_channel.notify_subscribers(msg)
199196

200197
def trigger_push_update(self) -> None:
@@ -208,14 +205,14 @@ class DyadSimulator(A01DeviceSimulator):
208205
def __init__(
209206
self,
210207
duid: str = "fake_dyad_duid",
211-
status: dict[int | enum.Enum, Any] | None = None,
208+
status: dict[Any, Any] | None = None,
212209
device_info: HomeDataDevice | None = None,
213210
product: HomeDataProduct | None = None,
214211
):
215212
product = product or DEFAULT_DYAD_PRODUCT
216213
if device_info is None:
217214
device_info = replace(DEFAULT_DYAD_DEVICE_INFO, duid=duid, name=f"Dyad {duid}")
218-
merged_status = copy.deepcopy(DEFAULT_DYAD_STATUS)
215+
merged_status: dict[int, Any] = copy.deepcopy(DEFAULT_DYAD_STATUS)
219216
if status:
220217
for k, v in status.items():
221218
merged_status[int(_extract_int_value(k))] = _extract_int_value(v)
@@ -249,14 +246,14 @@ class ZeoSimulator(A01DeviceSimulator):
249246
def __init__(
250247
self,
251248
duid: str = "fake_zeo_duid",
252-
status: dict[int | enum.Enum, Any] | None = None,
249+
status: dict[Any, Any] | None = None,
253250
device_info: HomeDataDevice | None = None,
254251
product: HomeDataProduct | None = None,
255252
):
256253
product = product or DEFAULT_ZEO_PRODUCT
257254
if device_info is None:
258255
device_info = replace(DEFAULT_ZEO_DEVICE_INFO, duid=duid, name=f"Zeo {duid}")
259-
merged_status = copy.deepcopy(DEFAULT_ZEO_STATUS)
256+
merged_status: dict[int, Any] = copy.deepcopy(DEFAULT_ZEO_STATUS)
260257
if status:
261258
for k, v in status.items():
262259
merged_status[int(_extract_int_value(k))] = _extract_int_value(v)

0 commit comments

Comments
 (0)