Skip to content

Commit 3eaed1d

Browse files
chore: linting
1 parent c6cc29b commit 3eaed1d

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

roborock/package_parser.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import logging
22

33
import click
4-
import pyshark
5-
from pyshark.capture.live_capture import UnknownInterfaceException
6-
from pyshark.packet.packet import Packet
4+
from pyshark import FileCapture # type: ignore
5+
from pyshark.capture.live_capture import LiveCapture, UnknownInterfaceException # type: ignore
6+
from pyshark.packet.packet import Packet # type: ignore
77

88
from roborock import RoborockException
99
from roborock.protocol import MessageParser
@@ -29,17 +29,15 @@ def cli(debug: int):
2929
async def parser(_, local_key, device_ip, file):
3030
file_provided = file is not None
3131
if file_provided:
32-
capture = pyshark.FileCapture(file)
32+
capture = FileCapture(file)
3333
else:
3434
_LOGGER.info("Listen for interface rvi0 since no file was provided")
35-
capture = pyshark.LiveCapture(interface="rvi0")
35+
capture = LiveCapture(interface="rvi0")
3636
buffer = {"data": bytes()}
3737

3838
def on_package(packet: Packet):
3939
if hasattr(packet, "ip"):
40-
if packet.transport_layer == "TCP" and (
41-
packet.ip.dst == device_ip or packet.ip.src == device_ip
42-
):
40+
if packet.transport_layer == "TCP" and (packet.ip.dst == device_ip or packet.ip.src == device_ip):
4341
if hasattr(packet, "DATA"):
4442
if hasattr(packet.DATA, "data"):
4543
if packet.ip.dst == device_ip:
@@ -66,9 +64,7 @@ def on_package(packet: Packet):
6664
try:
6765
await capture.packets_from_tshark(on_package, close_tshark=not file_provided)
6866
except UnknownInterfaceException:
69-
raise RoborockException(
70-
"You need to run 'rvictl -s XXXXXXXX-XXXXXXXXXXXXXXXX' first, with an iPhone connected"
71-
)
67+
raise RoborockException("You need to run 'rvictl -s XXXXXXXX-XXXXXXXXXXXXXXXX' first, with an iPhone connected")
7268

7369

7470
cli.add_command(parser)

0 commit comments

Comments
 (0)