Fix some outstanding pylint issues (or disable the checks)

This commit is contained in:
Ian McEwen
2024-03-19 12:35:42 -07:00
parent 0528a6fb3b
commit b8640666d7
10 changed files with 17 additions and 17 deletions

View File

@@ -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(

View File

@@ -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

View File

@@ -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)

View File

@@ -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"]}'

View File

@@ -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

View File

@@ -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):

View File

@@ -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

View File

@@ -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)

View File

@@ -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()

View File

@@ -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