Skip to content

Commit

Permalink
fix type warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
geeksville committed Jun 25, 2024
1 parent 2202414 commit 402622f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions meshtastic/powermon/ppk2.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""code logging power consumption of meshtastic devices."""
"""Classes for logging power consumption of meshtastic devices."""

import logging
from typing import Optional

from ppk2_api import ppk2_api
from ppk2_api import ppk2_api # type: ignore[import-untyped]

from .power_supply import PowerError, PowerSupply

Expand Down
2 changes: 1 addition & 1 deletion meshtastic/slog/arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,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")
self.sink = pa.OSFile(file_name, "wb") # type: ignore
self.new_rows: list[dict] = []
self.schema: pa.Schema | None = None # haven't yet learned the schema
self.writer: pa.RecordBatchFileWriter | None = None

Check warning on line 19 in meshtastic/slog/arrow.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/slog/arrow.py#L16-L19

Added lines #L16 - L19 were not covered by tests
Expand Down
17 changes: 9 additions & 8 deletions meshtastic/slog/slog.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from datetime import datetime
from typing import Optional

import parse
import parse # type: ignore[import-untyped]
import platformdirs
from pubsub import pub # type: ignore[import-untyped]

Expand All @@ -25,7 +25,7 @@ class LogDef:
"""Log definition."""

code: str # i.e. PM or B or whatever... see meshtastic slog documentation
format: str # A format string that can be used to parse the arguments
format: parse.Parser # A format string that can be used to parse the arguments

def __init__(self, code: str, fmt: str) -> None:
"""Initialize the LogDef object.
Expand Down Expand Up @@ -138,7 +138,7 @@ def __init__(
self,
client: MeshInterface,
dir_name: Optional[str] = None,
power_meter: PowerMeter = None,
power_meter: Optional[PowerMeter] = None,
) -> None:
"""Initialize the PowerMonClient object.
Expand All @@ -156,11 +156,12 @@ def __init__(

logging.info(f"Writing slogs to {dir_name}")

Check warning on line 157 in meshtastic/slog/slog.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/slog/slog.py#L157

Added line #L157 was not covered by tests

self.slog_logger = StructuredLogger(client, self.dir_name)
if power_meter:
self.power_logger = PowerLogger(power_meter, f"{self.dir_name}/power.arrow")
else:
self.power_logger = None
self.slog_logger: Optional[StructuredLogger] = StructuredLogger(client, self.dir_name)
self.power_logger: Optional[PowerLogger] = (

Check warning on line 160 in meshtastic/slog/slog.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/slog/slog.py#L159-L160

Added lines #L159 - L160 were not covered by tests
None
if not power_meter
else PowerLogger(power_meter, f"{self.dir_name}/power.arrow")
)

# Store a lambda so we can find it again to unregister
self.atexit_handler = lambda: self.close() # pylint: disable=unnecessary-lambda

Check warning on line 167 in meshtastic/slog/slog.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/slog/slog.py#L167

Added line #L167 was not covered by tests
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ riden = { git = "https://github.com/geeksville/riden.git#1.2.1" }
parse = "^1.20.2"
ppk2-api = "^0.9.2"
pyarrow = "^16.1.0"
pyarrow-stubs = "^10.0.1.7"
platformdirs = "^4.2.2"

[tool.poetry.group.dev.dependencies]
Expand All @@ -45,6 +44,7 @@ types-tabulate = "^0.9.0.20240106"
types-requests = "^2.31.0.20240406"
types-setuptools = "^69.5.0.20240423"
types-pyyaml = "^6.0.12.20240311"
pyarrow-stubs = "^10.0.1.7"

[tool.poetry.extras]
tunnel = ["pytap2"]
Expand Down

0 comments on commit 402622f

Please sign in to comment.