From b8640666d727521322fe03fbf6c6d846cb81b688 Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Tue, 19 Mar 2024 12:35:42 -0700 Subject: [PATCH] Fix some outstanding pylint issues (or disable the checks) --- meshtastic/__main__.py | 2 +- meshtastic/globals.py | 2 +- meshtastic/mesh_interface.py | 7 +++---- meshtastic/node.py | 5 ++--- meshtastic/stream_interface.py | 2 +- meshtastic/tests/test_main.py | 4 ++-- meshtastic/tests/test_node.py | 2 +- meshtastic/tests/test_util.py | 2 +- meshtastic/util.py | 4 ++-- meshtastic/version.py | 4 +++- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/meshtastic/__main__.py b/meshtastic/__main__.py index 13c5af4..3e7d4a4 100644 --- a/meshtastic/__main__.py +++ b/meshtastic/__main__.py @@ -1260,7 +1260,7 @@ def initParser(): help="Request telemetry from a node. " "You need pass the destination ID as argument with '--dest'. " "For repeaters, the nodeNum is required.", - action="store_true", + action="store_true", ) parser.add_argument( diff --git a/meshtastic/globals.py b/meshtastic/globals.py index 07ae2e3..0673de6 100644 --- a/meshtastic/globals.py +++ b/meshtastic/globals.py @@ -24,7 +24,7 @@ class Globals: def __init__(self): """Constructor for the Globals CLass""" if Globals.__instance is not None: - raise Exception("This class is a singleton") + raise Exception("This class is a singleton") # pylint: disable=W0719 else: Globals.__instance = self self.args = None diff --git a/meshtastic/mesh_interface.py b/meshtastic/mesh_interface.py index 5f5b56d..cf64205 100644 --- a/meshtastic/mesh_interface.py +++ b/meshtastic/mesh_interface.py @@ -23,7 +23,6 @@ from meshtastic.__init__ import ( BROADCAST_ADDR, BROADCAST_NUM, LOCAL_ADDR, - OUR_APP_VERSION, ResponseHandler, protocols, publishingThread, @@ -440,7 +439,7 @@ class MeshInterface: destinationId = int(destinationId[1:], 16) else: destinationId = int(destinationId) - + self.sendData( r, destinationId=destinationId, @@ -469,7 +468,7 @@ class MeshInterface: ) if telemetry.device_metrics.air_util_tx is not None: print(f"Transmit air utilization: {telemetry.device_metrics.air_util_tx:.2f}%") - + elif p["decoded"]["portnum"] == 'ROUTING_APP': if p["decoded"]["routing"]["errorReason"] == 'NO_RESPONSE': our_exit("No response from node. At least firmware 2.1.22 is required on the destination node.") @@ -556,7 +555,7 @@ class MeshInterface: success = self._timeout.waitForTraceRoute(waitFactor, self._acknowledgment) if not success: raise Exception("Timed out waiting for traceroute") - + def waitForTelemetry(self): """Wait for telemetry""" success = self._timeout.waitForTelemetry(self._acknowledgment) diff --git a/meshtastic/node.py b/meshtastic/node.py index c5a57bd..9df4b50 100644 --- a/meshtastic/node.py +++ b/meshtastic/node.py @@ -115,6 +115,7 @@ class Node: print(f"{str(camel_to_snake(field))}:\n{str(config_values)}") def requestConfig(self, configType): + """Request the config from the node via admin message""" if self == self.iface.localNode: onResponse = None else: @@ -688,9 +689,6 @@ class Node: logging.debug(f"Received channel {stripnl(c)}") index = c.index - # for stress testing, we can always download all channels - fastChannelDownload = True - if index >= 8 - 1: logging.debug("Finished downloading channels") @@ -703,6 +701,7 @@ class Node: self._requestChannel(index + 1) def onAckNak(self, p): + """Informative handler for ACK/NAK responses""" if p["decoded"]["routing"]["errorReason"] != "NONE": print( f'Received a NAK, error reason: {p["decoded"]["routing"]["errorReason"]}' diff --git a/meshtastic/stream_interface.py b/meshtastic/stream_interface.py index fd0daeb..b5dc894 100644 --- a/meshtastic/stream_interface.py +++ b/meshtastic/stream_interface.py @@ -32,7 +32,7 @@ class StreamInterface(MeshInterface): """ if not hasattr(self, "stream") and not noProto: - raise Exception( + raise Exception( # pylint: disable=W0719 "StreamInterface is now abstract (to update existing code create SerialInterface instead)" ) self._rxBuf = bytes() # empty diff --git a/meshtastic/tests/test_main.py b/meshtastic/tests/test_main.py index 23d7e5e..6a0312a 100644 --- a/meshtastic/tests/test_main.py +++ b/meshtastic/tests/test_main.py @@ -23,7 +23,7 @@ from meshtastic.__main__ import ( tunnelMain, ) -from ..channel_pb2 import Channel +from ..channel_pb2 import Channel # pylint: disable=E0611 # from ..ble_interface import BLEInterface from ..node import Node @@ -388,7 +388,7 @@ def test_main_onConnected_exception(capsys): Globals.getInstance().set_args(sys.argv) def throw_an_exception(junk): - raise Exception("Fake exception.") + raise Exception("Fake exception.") # pylint: disable=W0719 iface = MagicMock(autospec=SerialInterface) with patch("meshtastic.serial_interface.SerialInterface", return_value=iface): diff --git a/meshtastic/tests/test_node.py b/meshtastic/tests/test_node.py index 8500ecd..5e1314e 100644 --- a/meshtastic/tests/test_node.py +++ b/meshtastic/tests/test_node.py @@ -7,7 +7,7 @@ from unittest.mock import MagicMock, patch import pytest # from ..admin_pb2 import AdminMessage -from ..channel_pb2 import Channel +from ..channel_pb2 import Channel # pylint: disable=E0611 from ..node import Node from ..serial_interface import SerialInterface diff --git a/meshtastic/tests/test_util.py b/meshtastic/tests/test_util.py index df760d1..b058b02 100644 --- a/meshtastic/tests/test_util.py +++ b/meshtastic/tests/test_util.py @@ -177,7 +177,7 @@ def test_catchAndIgnore(caplog): """Test catchAndIgnore() does not actually throw an exception, but just logs""" def some_closure(): - raise Exception("foo") + raise Exception("foo") # pylint: disable=W0719 with caplog.at_level(logging.DEBUG): catchAndIgnore("something", some_closure) diff --git a/meshtastic/util.py b/meshtastic/util.py index 0c2fd44..d6b6040 100644 --- a/meshtastic/util.py +++ b/meshtastic/util.py @@ -109,7 +109,7 @@ def stripnl(s): def fixme(message): """Raise an exception for things that needs to be fixed""" - raise Exception(f"FIXME: {message}") + raise Exception(f"FIXME: {message}") # pylint: disable=W0719 def catchAndIgnore(reason, closure): @@ -193,7 +193,7 @@ class Timeout: return True time.sleep(self.sleepInterval) return False - + def waitForTelemetry(self, acknowledgment): """Block until telemetry response is received. Returns True if telemetry response has been received.""" self.reset() diff --git a/meshtastic/version.py b/meshtastic/version.py index bdc69eb..1856fd5 100644 --- a/meshtastic/version.py +++ b/meshtastic/version.py @@ -1,3 +1,4 @@ +"""Version lookup utilities, isolated for cleanliness""" import sys try: from importlib.metadata import version @@ -5,7 +6,8 @@ except: import pkg_resources def get_active_version(): + """Get the currently active version using importlib, or pkg_resources if we must""" if "importlib.metadata" in sys.modules: return version("meshtastic") else: - return pkg_resources.get_distribution("meshtastic").version + return pkg_resources.get_distribution("meshtastic").version # pylint: disable=E0601