From 6194e41baf979285291926293ec2a5095ba0cbc5 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Sat, 29 Jun 2024 14:37:50 -0700 Subject: [PATCH] fix linter warnings --- meshtastic/__main__.py | 3 +-- meshtastic/ble_interface.py | 17 +++++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/meshtastic/__main__.py b/meshtastic/__main__.py index 8bebf41..7458e66 100644 --- a/meshtastic/__main__.py +++ b/meshtastic/__main__.py @@ -1044,7 +1044,6 @@ def common(): for x in BLEInterface.scan(): print(f"Found: name='{x.name}' address='{x.address}'") meshtastic.util.our_exit("BLE scan finished", 0) - return elif args.ble: client = BLEInterface(args.ble_dest, debugOut=logfile, noProto=args.noproto, noNodes=args.no_nodes) elif args.host: @@ -1122,7 +1121,7 @@ def addConnectionArgs(parser: argparse.ArgumentParser) -> argparse.ArgumentParse "--ble-dest", help="The BLE device address or name to connect to", default=None, - ) + ) return parser diff --git a/meshtastic/ble_interface.py b/meshtastic/ble_interface.py index 0b5c8b7..4c24528 100644 --- a/meshtastic/ble_interface.py +++ b/meshtastic/ble_interface.py @@ -9,10 +9,9 @@ from threading import Thread from typing import Optional from bleak import BleakClient, BleakScanner, BLEDevice -from print_color import print +import print_color from meshtastic.mesh_interface import MeshInterface -from meshtastic.util import our_exit SERVICE_UUID = "6ba1b218-15a8-461f-9fa8-5dcae273eafd" TORADIO_UUID = "f75c76d2-129e-4dad-a1dd-7866124401e7" @@ -27,8 +26,6 @@ class BLEInterface(MeshInterface): class BLEError(Exception): """An exception class for BLE errors.""" - pass - def __init__( self, address: Optional[str], @@ -85,15 +82,15 @@ class BLEInterface(MeshInterface): async def log_radio_handler(self, _, b): # pylint: disable=C0116 log_radio = b.decode("utf-8").replace("\n", "") if log_radio.startswith("DEBUG"): - print(log_radio, color="cyan", end=None) + print_color.print(log_radio, color="cyan", end=None) elif log_radio.startswith("INFO"): - print(log_radio, color="white", end=None) + print_color.print(log_radio, color="white", end=None) elif log_radio.startswith("WARN"): - print(log_radio, color="yellow", end=None) + print_color.print(log_radio, color="yellow", end=None) elif log_radio.startswith("ERROR"): - print(log_radio, color="red", end=None) + print_color.print(log_radio, color="red", end=None) else: - print(log_radio, end=None) + print_color.print(log_radio, end=None) @staticmethod def scan() -> list[BLEDevice]: @@ -122,7 +119,7 @@ class BLEInterface(MeshInterface): if address: addressed_devices = list( filter( - lambda x: address == x.name or address == x.address, + lambda x: address in (x.name, x.address), addressed_devices, ) )