Skip to content

Commit 84ffdcd

Browse files
authored
Merge pull request #647 from ianmcorvidae/improve-mypy
Add/update some types to be at least as backwards-compatible as we can be
2 parents fd4282b + 5366ddf commit 84ffdcd

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

meshtastic/analysis/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import argparse
44
import logging
5-
from typing import cast
5+
from typing import cast, List
66

77
import dash_bootstrap_components as dbc # type: ignore[import-untyped]
88
import numpy as np
@@ -20,7 +20,7 @@
2020
pd.options.mode.copy_on_write = True
2121

2222

23-
def to_pmon_names(arr) -> list[str]:
23+
def to_pmon_names(arr) -> List[str]:
2424
"""Convert the power monitor state numbers to their corresponding names.
2525
2626
arr (list): List of power monitor state numbers.

meshtastic/slog/arrow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import logging
44
import threading
55
import os
6-
from typing import Optional
6+
from typing import Optional, List
77

88
import pyarrow as pa
99
from pyarrow import feather
@@ -20,7 +20,7 @@ def __init__(self, file_name: str):
2020
file_name (str): The name of the file to write to.
2121
"""
2222
self.sink = pa.OSFile(file_name, "wb") # type: ignore
23-
self.new_rows: list[dict] = []
23+
self.new_rows: List[dict] = []
2424
self.schema: Optional[pa.Schema] = None # haven't yet learned the schema
2525
self.writer: Optional[pa.RecordBatchStreamWriter] = None
2626
self._lock = threading.Condition() # Ensure only one thread writes at a time

meshtastic/slog/slog.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from dataclasses import dataclass
1111
from datetime import datetime
1212
from functools import reduce
13-
from typing import Optional
13+
from typing import Optional, List, Tuple
1414

1515
import parse # type: ignore[import-untyped]
1616
import platformdirs
@@ -39,10 +39,10 @@ class LogDef:
3939
"""Log definition."""
4040

4141
code: str # i.e. PM or B or whatever... see meshtastic slog documentation
42-
fields: list[tuple[str, pa.DataType]] # A list of field names and their arrow types
42+
fields: List[Tuple[str, pa.DataType]] # A list of field names and their arrow types
4343
format: parse.Parser # A format string that can be used to parse the arguments
4444

45-
def __init__(self, code: str, fields: list[tuple[str, pa.DataType]]) -> None:
45+
def __init__(self, code: str, fields: List[Tuple[str, pa.DataType]]) -> None:
4646
"""Initialize the LogDef object.
4747
4848
code (str): The code.
@@ -93,7 +93,7 @@ def __init__(self, pMeter: PowerMeter, file_path: str, interval=0.002) -> None:
9393
)
9494
self.thread.start()
9595

96-
def store_current_reading(self, now: datetime | None = None) -> None:
96+
def store_current_reading(self, now: Optional[datetime] = None) -> None:
9797
"""Store current power measurement."""
9898
if now is None:
9999
now = datetime.now()
@@ -133,7 +133,7 @@ def __init__(
133133
self,
134134
client: MeshInterface,
135135
dir_path: str,
136-
power_logger: PowerLogger | None = None,
136+
power_logger: Optional[PowerLogger] = None,
137137
include_raw=True,
138138
) -> None:
139139
"""Initialize the StructuredLogger object.

0 commit comments

Comments
 (0)