Skip to content

Commit 18528b1

Browse files
committed
Run ruff format
1 parent 991e1d1 commit 18528b1

10 files changed

Lines changed: 43 additions & 32 deletions

File tree

deebot_client/commands/xml/clean.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Clean(ExecuteCommand):
2626
HAS_SUB_ELEMENT = True
2727

2828
def __init__(
29-
self, action: CleanAction, speed: FanSpeedLevel = FanSpeedLevel.NORMAL
29+
self, action: CleanAction, speed: FanSpeedLevel = FanSpeedLevel.NORMAL
3030
) -> None:
3131
# <ctl><clean type='SpotArea' act='s' speed='standard' deep='1' mid='4,5'/></ctl>
3232

@@ -46,11 +46,11 @@ class CleanArea(ExecuteCommand):
4646
HAS_SUB_ELEMENT = True
4747

4848
def __init__(
49-
self,
50-
mode: CleanMode,
51-
area: str,
52-
cleanings: int = 1,
53-
speed: FanSpeedLevel = FanSpeedLevel.NORMAL,
49+
self,
50+
mode: CleanMode,
51+
area: str,
52+
cleanings: int = 1,
53+
speed: FanSpeedLevel = FanSpeedLevel.NORMAL,
5454
) -> None:
5555
# <ctl><clean type='SpotArea' act='s' speed='standard' deep='1' mid='4,5'/></ctl>
5656

deebot_client/commands/xml/clean_logs.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ def _handle_xml(cls, event_bus: EventBus, xml: Element) -> HandlingResult:
3737
3838
:return: A message response
3939
"""
40-
if xml.attrib.get("ret") != "ok" or (resp_logs := xml.findall("CleanSt")) is None:
40+
if (
41+
xml.attrib.get("ret") != "ok"
42+
or (resp_logs := xml.findall("CleanSt")) is None
43+
):
4144
return HandlingResult.analyse()
4245

4346
if len(resp_logs) >= 0:

deebot_client/commands/xml/common.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ def handle_mqtt_p2p(
108108
data = response_payload
109109
else:
110110
msg = "Unsupported message data type {message_type}"
111-
raise TypeError(
112-
msg.format(essage_type=type(response_payload))
113-
)
111+
raise TypeError(msg.format(essage_type=type(response_payload)))
114112
self._handle_mqtt_p2p(event_bus, data)
115113

116114
@abstractmethod

deebot_client/commands/xml/water_info.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class GetWaterPermeability(XmlGetCommand):
2525

2626
@classmethod
2727
def handle_set_args(
28-
cls, event_bus: EventBus, args: dict[str, Any]
28+
cls, event_bus: EventBus, args: dict[str, Any]
2929
) -> HandlingResult:
3030
"""Handle message->body->data and notify the correct event subscribers.
3131
@@ -54,13 +54,17 @@ class GetWaterBoxInfo(XmlGetCommand):
5454

5555
@classmethod
5656
def handle_set_args(
57-
cls, event_bus: EventBus, args: dict[str, Any]
57+
cls, event_bus: EventBus, args: dict[str, Any]
5858
) -> HandlingResult:
5959
"""Handle message->body->data and notify the correct event subscribers.
6060
6161
:return: A message response
6262
"""
63-
event_bus.notify(WaterInfoEvent(amount=WaterAmount.HIGH, mop_attached=(str(args["on"]) != "0")))
63+
event_bus.notify(
64+
WaterInfoEvent(
65+
amount=WaterAmount.HIGH, mop_attached=(str(args["on"]) != "0")
66+
)
67+
)
6468
return HandlingResult.success()
6569

6670
@classmethod
@@ -72,5 +76,7 @@ def _handle_xml(cls, event_bus: EventBus, xml: Element) -> HandlingResult:
7276
if xml.attrib.get("ret") != "ok" or not (on := xml.attrib.get("on")):
7377
return HandlingResult.analyse()
7478

75-
event_bus.notify(WaterInfoEvent(amount=WaterAmount.HIGH, mop_attached=on != "0"))
79+
event_bus.notify(
80+
WaterInfoEvent(amount=WaterAmount.HIGH, mop_attached=on != "0")
81+
)
7682
return HandlingResult.success()

deebot_client/device.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ class Device:
4646
"""Device representation."""
4747

4848
def __init__(
49-
self,
50-
device_info: DeviceInfo,
51-
authenticator: Authenticator,
49+
self,
50+
device_info: DeviceInfo,
51+
authenticator: Authenticator,
5252
) -> None:
5353
self._device_info = device_info
5454
self.device_info: Final = device_info.api
@@ -78,8 +78,8 @@ async def on_pos(event: PositionsEvent) -> None:
7878
if deebot:
7979
on_charger = filter(
8080
lambda p: p.type == PositionType.CHARGER
81-
and p.x == deebot.x
82-
and p.y == deebot.y,
81+
and p.x == deebot.x
82+
and p.y == deebot.y,
8383
event.positions,
8484
)
8585
if on_charger:
@@ -146,12 +146,12 @@ async def teardown(self) -> None:
146146
async def _available_task_worker(self) -> None:
147147
while True:
148148
if (datetime.now() - self._last_time_available).total_seconds() > (
149-
_AVAILABLE_CHECK_INTERVAL - 1
149+
_AVAILABLE_CHECK_INTERVAL - 1
150150
):
151151
tasks: set[asyncio.Future[Any]] = set()
152152
try:
153153
for command in self.capabilities.get_refresh_commands(
154-
AvailabilityEvent
154+
AvailabilityEvent
155155
):
156156
tasks.add(asyncio.create_task(self._execute_command(command)))
157157

@@ -166,8 +166,8 @@ async def _available_task_worker(self) -> None:
166166
await asyncio.sleep(_AVAILABLE_CHECK_INTERVAL)
167167

168168
async def _execute_command(
169-
self,
170-
command: Command,
169+
self,
170+
command: Command,
171171
) -> DeviceCommandResult:
172172
"""Execute given command."""
173173
async with self._semaphore:
@@ -187,7 +187,7 @@ def _set_available(self, *, available: bool) -> None:
187187
self.events.notify(AvailabilityEvent(available=available))
188188

189189
def _handle_message(
190-
self, message_name: str, message_data: str | bytes | bytearray | dict[str, Any]
190+
self, message_name: str, message_data: str | bytes | bytearray | dict[str, Any]
191191
) -> None:
192192
"""Handle the given message.
193193
@@ -215,7 +215,9 @@ def _handle_message(
215215
else:
216216
msg = "Unsupported message data type {message_name}: {message_type}"
217217
raise TypeError(
218-
msg.format(message_name=message_name, message_type=type(message_data))
218+
msg.format(
219+
message_name=message_name, message_type=type(message_data)
220+
)
219221
)
220222

221223
if isinstance(data, dict):

deebot_client/messages/xml/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"CleanSt",
2222
"MapP",
2323
"Pos",
24-
"WaterBoxInfo"
24+
"WaterBoxInfo",
2525
]
2626
# fmt: off
2727
# ordered by file asc

deebot_client/messages/xml/battery.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ def _handle_xml(cls, event_bus: EventBus, xml: Element) -> HandlingResult:
2525
2626
:return: A message response
2727
"""
28-
if (
29-
(battery := xml.find("battery")) is None
30-
or (power := battery.attrib.get("power")) is None
31-
):
28+
if (battery := xml.find("battery")) is None or (
29+
power := battery.attrib.get("power")
30+
) is None:
3231
return HandlingResult.analyse()
3332

3433
if power:

deebot_client/messages/xml/clean.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
_LOGGER = get_logger(__name__)
1919

20+
2021
class CleanSt(XmlMessage):
2122
"""CleanSt message."""
2223

deebot_client/messages/xml/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def _handle_str(cls, event_bus: EventBus, message: str) -> HandlingResult:
2424
2525
:return: A message response
2626
"""
27-
xml = ET.fromstring(message) # noqa: S314
27+
xml = ET.fromstring(message) # noqa: S314
2828
return cls._handle_xml(event_bus, xml)
2929

3030
@classmethod

deebot_client/messages/xml/water_info.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,7 @@ def _handle_xml(cls, event_bus: EventBus, xml: Element) -> HandlingResult:
2828
if (on := xml.attrib.get("on")) is None:
2929
return HandlingResult.analyse()
3030

31-
event_bus.notify(WaterInfoEvent(amount=WaterAmount.HIGH, mop_attached=on != "0"))
31+
event_bus.notify(
32+
WaterInfoEvent(amount=WaterAmount.HIGH, mop_attached=on != "0")
33+
)
3234
return HandlingResult.success()

0 commit comments

Comments
 (0)