From 1b045bec884662d8628930d68b0a48ec4857bbe6 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Tue, 25 Jun 2024 11:02:24 -0700 Subject: [PATCH] fix linter warnings --- meshtastic/powermon/__init__.py | 6 +++--- meshtastic/powermon/ppk2.py | 4 +--- meshtastic/powermon/sim.py | 3 +-- meshtastic/slog/arrow.py | 2 ++ meshtastic/slog/slog.py | 17 +++++++++-------- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/meshtastic/powermon/__init__.py b/meshtastic/powermon/__init__.py index 9db5544..a8f578f 100644 --- a/meshtastic/powermon/__init__.py +++ b/meshtastic/powermon/__init__.py @@ -1,6 +1,6 @@ """Support for logging from power meters/supplies.""" -from .power_supply import PowerMeter, PowerSupply, PowerError -from .riden import RidenPowerSupply +from .power_supply import PowerError, PowerMeter, PowerSupply from .ppk2 import PPK2PowerSupply -from .sim import SimPowerSupply \ No newline at end of file +from .riden import RidenPowerSupply +from .sim import SimPowerSupply diff --git a/meshtastic/powermon/ppk2.py b/meshtastic/powermon/ppk2.py index 79f87ff..3f8c67f 100644 --- a/meshtastic/powermon/ppk2.py +++ b/meshtastic/powermon/ppk2.py @@ -1,7 +1,7 @@ """code logging power consumption of meshtastic devices.""" import logging -from typing import * +from typing import Optional from ppk2_api import ppk2_api @@ -56,5 +56,3 @@ class PPK2PowerSupply(PowerSupply): def powerOff(self): """Power off the supply.""" self.r.toggle_DUT_power("OFF") - - diff --git a/meshtastic/powermon/sim.py b/meshtastic/powermon/sim.py index c66c5b3..e7e8484 100644 --- a/meshtastic/powermon/sim.py +++ b/meshtastic/powermon/sim.py @@ -2,9 +2,8 @@ import math import time -from typing import * -from .power_supply import PowerError, PowerSupply +from .power_supply import PowerSupply class SimPowerSupply(PowerSupply): diff --git a/meshtastic/slog/arrow.py b/meshtastic/slog/arrow.py index 157f581..71703c1 100644 --- a/meshtastic/slog/arrow.py +++ b/meshtastic/slog/arrow.py @@ -1,3 +1,5 @@ +"""Utilities for Apache Arrow serialization.""" + import pyarrow as pa chunk_size = 1000 # disk writes are batched based on this number of rows diff --git a/meshtastic/slog/slog.py b/meshtastic/slog/slog.py index 9bee592..720886a 100644 --- a/meshtastic/slog/slog.py +++ b/meshtastic/slog/slog.py @@ -2,10 +2,10 @@ import atexit import logging +import os import re import threading import time -import os from dataclasses import dataclass from datetime import datetime from typing import Optional @@ -18,7 +18,6 @@ from meshtastic.mesh_interface import MeshInterface from meshtastic.powermon import PowerMeter from .arrow import ArrowWriter -import os @dataclass(init=False) @@ -58,7 +57,9 @@ class PowerLogger: self.writer = ArrowWriter(file_path) self.interval = interval self.is_logging = True - self.thread = threading.Thread(target=self._logging_thread, name="PowerLogger", daemon=True) + self.thread = threading.Thread( + target=self._logging_thread, name="PowerLogger", daemon=True + ) self.thread.start() def _logging_thread(self) -> None: @@ -92,10 +93,9 @@ class StructuredLogger: """ self.client = client self.writer = ArrowWriter(f"{dir_path}/slog.arrow") - # trunk-ignore(pylint/R1732) self.raw_file = open( f"{dir_path}/raw.txt", "w", encoding="utf8" - ) + ) # pylint: disable=consider-using-with self.listener = pub.subscribe(self._onLogMessage, TOPIC_MESHTASTIC_LOG_LINE) def close(self) -> None: @@ -163,15 +163,16 @@ class LogSet: self.power_logger = None # Store a lambda so we can find it again to unregister - self.atexit_handler = lambda: self.close() - atexit.register(self.close) + self.atexit_handler = lambda: self.close() # pylint: disable=unnecessary-lambda def close(self) -> None: """Close the log set.""" if self.slog_logger: logging.info(f"Closing slogs in {self.dir_name}") - atexit.unregister(self.atexit_handler) # docs say it will silently ignore if not found + atexit.unregister( + self.atexit_handler + ) # docs say it will silently ignore if not found self.slog_logger.close() if self.power_logger: self.power_logger.close()