mirror of
https://github.com/meshtastic/python.git
synced 2025-12-31 11:57:57 -05:00
Merge pull request #647 from ianmcorvidae/improve-mypy
Add/update some types to be at least as backwards-compatible as we can be
This commit is contained in:
@@ -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
|
||||
@@ -20,7 +20,7 @@ from ..slog import root_dir
|
||||
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.
|
||||
|
||||
@@ -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
|
||||
@@ -20,7 +20,7 @@ class ArrowWriter:
|
||||
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
|
||||
|
||||
@@ -10,7 +10,7 @@ import time
|
||||
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
|
||||
@@ -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.
|
||||
@@ -93,7 +93,7 @@ class PowerLogger:
|
||||
)
|
||||
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()
|
||||
@@ -133,7 +133,7 @@ class StructuredLogger:
|
||||
self,
|
||||
client: MeshInterface,
|
||||
dir_path: str,
|
||||
power_logger: PowerLogger | None = None,
|
||||
power_logger: Optional[PowerLogger] = None,
|
||||
include_raw=True,
|
||||
) -> None:
|
||||
"""Initialize the StructuredLogger object.
|
||||
|
||||
Reference in New Issue
Block a user