diff --git a/src/infuse_iot/diff.py b/src/infuse_iot/diff.py index e8082f0..815c9ad 100644 --- a/src/infuse_iot/diff.py +++ b/src/infuse_iot/diff.py @@ -6,7 +6,7 @@ import binascii from collections import defaultdict -from typing import List, Dict, Tuple +from typing import List, Dict class ValidationError(Exception): @@ -267,7 +267,6 @@ def __str__(self): class WriteInstr(Instr): class WriteU4(ctypes.LittleEndianStructure): op = OpCode.WRITE_LEN_U4 - length = 1 _fields_ = [ ("opcode", ctypes.c_uint8), ] diff --git a/src/infuse_iot/epacket.py b/src/infuse_iot/epacket.py index a4abef7..0f06643 100644 --- a/src/infuse_iot/epacket.py +++ b/src/infuse_iot/epacket.py @@ -6,7 +6,7 @@ import time import random -from typing import List, Dict, Tuple, Any +from typing import List, Dict, Tuple from typing_extensions import Self from infuse_iot.util.crypto import chachapoly_decrypt, chachapoly_encrypt diff --git a/src/infuse_iot/rpc_wrappers/bt_disconnect.py b/src/infuse_iot/rpc_wrappers/bt_disconnect.py index a6164e5..6ddba02 100644 --- a/src/infuse_iot/rpc_wrappers/bt_disconnect.py +++ b/src/infuse_iot/rpc_wrappers/bt_disconnect.py @@ -6,7 +6,6 @@ from infuse_iot.generated.rpc_definitions import ( rpc_struct_bt_addr_le, rpc_enum_bt_le_addr_type, - rpc_enum_infuse_bt_characteristic, ) from infuse_iot.util.argparse import BtLeAddress from infuse_iot.util.ctypes import bytes_to_uint8 diff --git a/src/infuse_iot/rpc_wrappers/wifi_scan.py b/src/infuse_iot/rpc_wrappers/wifi_scan.py index 41b19d5..1f49ab5 100644 --- a/src/infuse_iot/rpc_wrappers/wifi_scan.py +++ b/src/infuse_iot/rpc_wrappers/wifi_scan.py @@ -20,7 +20,6 @@ class response(ctypes.LittleEndianStructure): @classmethod def from_buffer_copy(cls, source, offset=0): values = [] - num = source[0] source = source[1:] while len(source) > 0: diff --git a/src/infuse_iot/tdf.py b/src/infuse_iot/tdf.py index 3f7f697..3da86e5 100644 --- a/src/infuse_iot/tdf.py +++ b/src/infuse_iot/tdf.py @@ -3,7 +3,7 @@ import ctypes import enum -from typing import List, Dict +from typing import List from infuse_iot.time import InfuseTime from infuse_iot.generated import tdf_definitions diff --git a/src/infuse_iot/tools/cloud.py b/src/infuse_iot/tools/cloud.py index 0262565..05a583e 100644 --- a/src/infuse_iot/tools/cloud.py +++ b/src/infuse_iot/tools/cloud.py @@ -158,7 +158,9 @@ class SubCommand(InfuseCommand): @classmethod def add_parser(cls, parser): - subparser = parser.add_subparsers(title="commands", metavar="") + subparser = parser.add_subparsers( + title="commands", metavar="", required=True + ) Organisations.add_parser(subparser) Boards.add_parser(subparser) diff --git a/src/infuse_iot/tools/csv_annotate.py b/src/infuse_iot/tools/csv_annotate.py index c874bd6..f6b9a9a 100644 --- a/src/infuse_iot/tools/csv_annotate.py +++ b/src/infuse_iot/tools/csv_annotate.py @@ -42,7 +42,6 @@ def make_plots(self): def run(self): from dash import Dash, dcc, html, Input, Output, State, callback - import numpy as np import pandas as pd # Read data, add label column @@ -53,8 +52,6 @@ def run(self): [self.labels[0] for _ in range(self.df.shape[0])], ) - # print(self.df.index.iloc[0]) - app = Dash() app.layout = html.Div( [ diff --git a/tox.ini b/tox.ini index 3174086..69fb1e2 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ # Benefits of using tox: # -# 1. makes sure we are testing west as installed by setup.py +# 1. makes sure we are testing module as installed by pyproject.toml # 2. avoid touching user global / system config files # 3. avoid touching any git repositories outside of tmpdirs # 4. ensure global / system config settings have no effect on the tests @@ -8,18 +8,27 @@ [tox] envlist=py3 -[pycodestyle] -# We explicitly disable the following errors: -# -# - E126: continuation line over-indented for hanging indent -# - E261: at least two spaces before inline comment -# - E302: expected 2 blank lines, found 1 -# - E305: expected 2 blank lines after class or function definition, found 1 -# - W504: line break after binary operator -ignore = E126,E261,E302,E305,W504 -# Don't lint setup.py, the .tox or python virtualenv directory, or the build directory -exclude = setup.py,.tox,.venv,build -max-line-length = 120 +[tool.ruff] +line-length = 120 +indent-width = 4 + +[tool.ruff.lint] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle + "F", # pyflakes + "I", # isort + "SIM", # flake8-simplify + "UP", # pyupgrade + "W", # pycodestyle warnings + ] +ignore = [ + "SIM108", # Allow if-else blocks instead of forcing ternary operator + "UP027", # deprecated pyupgrade rule + ] + +[tool.ruff.format] +line-ending = "lf" [testenv] deps = @@ -27,10 +36,10 @@ deps = pytest pytest-cov types-PyYAML - black + ruff setenv = # For instance: ./.tox/py3/tmp/ TOXTEMPDIR={envtmpdir} commands = python -m pytest --basetemp='{envtmpdir}/pytest with space/' - python -m black --check '{toxinidir}' --extend-exclude 'api_client|tdf_definitions.py|rpc_definitions.py' + python -m ruff check '{toxinidir}' --extend-exclude 'api_client|tdf_definitions.py|rpc_definitions.py'