Skip to content

Commit 1cd1aed

Browse files
committed
Fix pylint/mypy stuff
1 parent ab14fb2 commit 1cd1aed

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

meshtastic/tests/firmware_harness.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,13 @@ def start(self, binary: str) -> None:
8989
self.workdir = tempfile.mkdtemp(prefix=f"mtd_node{self.node_id}_")
9090
vfs_dir = os.path.join(self.workdir, "vfs")
9191
os.mkdir(vfs_dir)
92-
log_stdout = open(os.path.join(self.workdir, "meshtasticd.log"), "wb", buffering=0)
93-
log_stderr = open(os.path.join(self.workdir, "meshtasticd.err"), "wb", buffering=0)
92+
# Files are closed in _kill(); keep them open for the process lifetime.
93+
log_stdout = open( # pylint: disable=consider-using-with
94+
os.path.join(self.workdir, "meshtasticd.log"), "wb", buffering=0
95+
)
96+
log_stderr = open( # pylint: disable=consider-using-with
97+
os.path.join(self.workdir, "meshtasticd.err"), "wb", buffering=0
98+
)
9499
self._log_files = [log_stdout, log_stderr]
95100
self.process = subprocess.Popen( # pylint: disable=consider-using-with
96101
[
@@ -244,9 +249,11 @@ def stop(self) -> None:
244249
self._started = False
245250

246251
def get_node(self, idx: int) -> SimNode:
252+
"""Return the SimNode at the given index."""
247253
return self.nodes[idx]
248254

249255
def get_iface(self, idx: int) -> TCPInterface:
256+
"""Return the TCPInterface for the node at the given index."""
250257
iface = self.nodes[idx].iface
251258
assert iface is not None, f"node {idx} has no interface"
252259
return iface

meshtastic/tests/test_smokemesh.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
according to this topology.
77
"""
88
import time
9-
from typing import List
9+
from typing import Any, Callable, List, Optional
1010

1111
import pytest
1212
from pubsub import pub # type: ignore[import-untyped]
@@ -19,11 +19,14 @@ class _PacketCollector:
1919

2020
def __init__(self):
2121
self.packets: List[dict] = []
22+
self._handler: Optional[Callable[..., Any]] = None
2223

2324
def on_receive(self, packet, interface): # pylint: disable=unused-argument
25+
"""Store a received packet."""
2426
self.packets.append(packet)
2527

2628
def wait_for(self, count: int, timeout: float = RECEIVE_TIMEOUT) -> bool:
29+
"""Wait until *count* packets have been collected or *timeout* expires."""
2730
deadline = time.monotonic() + timeout
2831
while time.monotonic() < deadline:
2932
if len(self.packets) >= count:
@@ -33,6 +36,7 @@ def wait_for(self, count: int, timeout: float = RECEIVE_TIMEOUT) -> bool:
3336

3437
@property
3538
def texts(self) -> List[str]:
39+
"""Return text payloads from TEXT_MESSAGE_APP packets."""
3640
return [
3741
p.get("decoded", {}).get("text", "")
3842
for p in self.packets
@@ -41,12 +45,14 @@ def texts(self) -> List[str]:
4145

4246
@property
4347
def traceroutes(self) -> List[dict]:
48+
"""Return TRACEROUTE_APP packets."""
4449
return [
4550
p for p in self.packets
4651
if p.get("decoded", {}).get("portnum") == "TRACEROUTE_APP"
4752
]
4853

4954
def reset(self):
55+
"""Clear all collected packets."""
5056
self.packets.clear()
5157

5258

0 commit comments

Comments
 (0)