Skip to content

Commit ba2d6c9

Browse files
committed
continue progressively typing things (SerialInterface/BLEInterface initializations)
1 parent fef0e1b commit ba2d6c9

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

meshtastic/ble_interface.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from threading import Thread, Event
88
from bleak import BleakScanner, BleakClient
99

10+
from typing import Optional
11+
1012
from meshtastic.mesh_interface import MeshInterface
1113
from meshtastic.util import our_exit
1214

@@ -30,7 +32,7 @@ class BLEState(): # pylint: disable=C0115
3032
MESH = False
3133

3234

33-
def __init__(self, address, noProto = False, debugOut = None):
35+
def __init__(self, address: Optional[str], noProto: bool = False, debugOut = None):
3436
self.state = BLEInterface.BLEState()
3537

3638
if not address:

meshtastic/serial_interface.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
import serial # type: ignore[import-untyped]
88

9+
from typing import Optional
10+
911
import meshtastic.util
1012
from meshtastic.stream_interface import StreamInterface
1113

@@ -16,7 +18,7 @@
1618
class SerialInterface(StreamInterface):
1719
"""Interface class for meshtastic devices over a serial link"""
1820

19-
def __init__(self, devPath=None, debugOut=None, noProto=False, connectNow=True):
21+
def __init__(self, devPath: Optional[str]=None, debugOut=None, noProto=False, connectNow=True):
2022
"""Constructor, opens a connection to a specified serial port, or if unspecified try to
2123
find one Meshtastic device by probing
2224
@@ -26,7 +28,7 @@ def __init__(self, devPath=None, debugOut=None, noProto=False, connectNow=True):
2628
"""
2729
self.noProto = noProto
2830

29-
self.devPath = devPath
31+
self.devPath: Optional[str] = devPath
3032

3133
if self.devPath is None:
3234
ports = meshtastic.util.findPorts(True)

meshtastic/util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import time
1212
import traceback
1313
from queue import Queue
14-
from typing import Union
14+
from typing import List, NoReturn, Union
1515

1616
from google.protobuf.json_format import MessageToJson
1717

@@ -122,7 +122,7 @@ def catchAndIgnore(reason, closure):
122122
logging.error(f"Exception thrown in {reason}: {ex}")
123123

124124

125-
def findPorts(eliminate_duplicates=False):
125+
def findPorts(eliminate_duplicates: bool=False) -> List[str]:
126126
"""Find all ports that might have meshtastic devices
127127
eliminate_duplicates will run the eliminate_duplicate_port() on the collection
128128
@@ -263,7 +263,7 @@ def _run(self):
263263
print(traceback.format_exc())
264264

265265

266-
def our_exit(message, return_value=1):
266+
def our_exit(message, return_value=1) -> NoReturn:
267267
"""Print the message and return a value.
268268
return_value defaults to 1 (non-successful)
269269
"""

0 commit comments

Comments
 (0)