Skip to content

Commit

Permalink
Merge pull request #647 from ianmcorvidae/improve-mypy
Browse files Browse the repository at this point in the history
Add/update some types to be at least as backwards-compatible as we can be
  • Loading branch information
ianmcorvidae authored Aug 8, 2024
2 parents fd4282b + 5366ddf commit 84ffdcd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions meshtastic/analysis/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import argparse
import logging
from typing import cast
from typing import cast, List

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


def to_pmon_names(arr) -> list[str]:
def to_pmon_names(arr) -> List[str]:
"""Convert the power monitor state numbers to their corresponding names.
arr (list): List of power monitor state numbers.
Expand Down
4 changes: 2 additions & 2 deletions meshtastic/slog/arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
import threading
import os
from typing import Optional
from typing import Optional, List

import pyarrow as pa
from pyarrow import feather
Expand All @@ -20,7 +20,7 @@ def __init__(self, file_name: str):
file_name (str): The name of the file to write to.
"""
self.sink = pa.OSFile(file_name, "wb") # type: ignore
self.new_rows: list[dict] = []
self.new_rows: List[dict] = []
self.schema: Optional[pa.Schema] = None # haven't yet learned the schema
self.writer: Optional[pa.RecordBatchStreamWriter] = None
self._lock = threading.Condition() # Ensure only one thread writes at a time
Expand Down
10 changes: 5 additions & 5 deletions meshtastic/slog/slog.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from dataclasses import dataclass
from datetime import datetime
from functools import reduce
from typing import Optional
from typing import Optional, List, Tuple

import parse # type: ignore[import-untyped]
import platformdirs
Expand Down Expand Up @@ -39,10 +39,10 @@ class LogDef:
"""Log definition."""

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

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

def store_current_reading(self, now: datetime | None = None) -> None:
def store_current_reading(self, now: Optional[datetime] = None) -> None:
"""Store current power measurement."""
if now is None:
now = datetime.now()
Expand Down Expand Up @@ -133,7 +133,7 @@ def __init__(
self,
client: MeshInterface,
dir_path: str,
power_logger: PowerLogger | None = None,
power_logger: Optional[PowerLogger] = None,
include_raw=True,
) -> None:
"""Initialize the StructuredLogger object.
Expand Down

0 comments on commit 84ffdcd

Please sign in to comment.