Use ruff and ruff format (#534)

Replaces the previously used linting and code formatting tools with ruff.
This commit is contained in:
Teemu R
2023-10-29 23:15:42 +01:00
committed by GitHub
parent 0061668c9f
commit c431dbb832
26 changed files with 220 additions and 174 deletions

View File

@@ -15,7 +15,7 @@ from kasa.protocol import TPLinkSmartHomeProtocol
def read_payloads_from_file(file):
"""Read the given pcap file and yield json payloads."""
pcap = dpkt.pcap.Reader(file)
for ts, pkt in pcap:
for _ts, pkt in pcap:
eth = Ethernet(pkt)
if eth.type != ETH_TYPE_IP:
continue
@@ -44,9 +44,8 @@ def read_payloads_from_file(file):
try:
json_payload = json.loads(decrypted)
except (
Exception
) as ex: # this can happen when the response is split into multiple tcp segments
except Exception as ex:
# this can happen when the response is split into multiple tcp segments
echo(f"[red]Unable to parse payload '{decrypted}', ignoring: {ex}[/red]")
continue
@@ -91,7 +90,8 @@ def parse_pcap(file):
context_str = f" [ctx: {context}]" if context else ""
echo(
f"[{is_success}] {direction}{context_str} {module}.{cmd}: {pf(response)}"
f"[{is_success}] {direction}{context_str} {module}.{cmd}:"
f" {pf(response)}"
)
echo(pf(seen_items))