Skip to content

Commit b85a9c3

Browse files
committed
FIX: Activate more linter rules
1 parent 62588e1 commit b85a9c3

File tree

8 files changed

+23
-28
lines changed

8 files changed

+23
-28
lines changed

MethodicConfigurator/annotate_params.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from typing import Any, Optional, Union
3636
from xml.etree import ElementTree as ET # no parsing, just data-structure manipulation
3737

38-
from defusedxml import ElementTree as DET # just parsing, no data-structure manipulation
38+
from defusedxml import ElementTree as DET # noqa: N814, just parsing, no data-structure manipulation
3939

4040
# URL of the XML file
4141
BASE_URL = "https://autotest.ardupilot.org/Parameters/"

MethodicConfigurator/backend_flightcontroller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def write(self, _buf) -> NoReturn: # noqa: ANN001
5353
msg = "write always fails"
5454
raise Exception(msg) # pylint: disable=broad-exception-raised
5555

56-
def inWaiting(self) -> int: # pylint: disable=invalid-name
56+
def inWaiting(self) -> int: # noqa: N802, pylint: disable=invalid-name
5757
return 0
5858

5959
def close(self) -> None:

MethodicConfigurator/backend_mavftp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from collections.abc import Generator
2323
from datetime import datetime
2424
from io import BufferedReader, BufferedWriter
25-
from io import BytesIO as SIO
25+
from io import BytesIO as SIO # noqa: N814
2626
from typing import Union
2727

2828
from pymavlink import mavutil

MethodicConfigurator/frontend_tkinter_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from logging import warning as logging_warning
1919
from platform import system as platform_system
2020
from tkinter import BooleanVar, messagebox, ttk
21-
from tkinter import font as tkFont
21+
from tkinter import font as tkFont # noqa: N812
2222
from typing import Optional, Union
2323

2424
from PIL import Image, ImageTk

MethodicConfigurator/tempcal_imu.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def __init__(self) -> None:
207207
self.accel: dict[int, dict[str, np.ndarray]] = {}
208208
self.gyro: dict[int, dict[str, np.ndarray]] = {}
209209

210-
def IMUs(self) -> list[int]:
210+
def IMUs(self) -> list[int]: # noqa: N802
211211
"""Return list of IMUs."""
212212
if len(self.accel.keys()) != len(self.gyro.keys()):
213213
print("accel and gyro data doesn't match")
@@ -242,7 +242,7 @@ def moving_average(self, data: np.ndarray, w: int) -> np.ndarray:
242242
ret[w:] = ret[w:] - ret[:-w]
243243
return ret[w - 1 :] / w
244244

245-
def FilterArray(self, data: dict[str, np.ndarray], width_s: int) -> dict[str, np.ndarray]:
245+
def filter_array(self, data: dict[str, np.ndarray], width_s: int) -> dict[str, np.ndarray]:
246246
"""Apply moving average filter of width width_s seconds."""
247247
nseconds = data["time"][-1] - data["time"][0]
248248
nsamples = len(data["time"])
@@ -252,11 +252,11 @@ def FilterArray(self, data: dict[str, np.ndarray], width_s: int) -> dict[str, np
252252
data[axis] = self.moving_average(data[axis], window)
253253
return data
254254

255-
def Filter(self, width_s: int) -> None:
255+
def filter(self, width_s: int) -> None:
256256
"""Apply moving average filter of width width_s seconds."""
257257
for imu in self.IMUs():
258-
self.accel[imu] = self.FilterArray(self.accel[imu], width_s)
259-
self.gyro[imu] = self.FilterArray(self.gyro[imu], width_s)
258+
self.accel[imu] = self.filter_array(self.accel[imu], width_s)
259+
self.gyro[imu] = self.filter_array(self.gyro[imu], width_s)
260260

261261
def accel_at_temp(self, imu: int, axis: str, temperature: float) -> float:
262262
"""Return the accel value closest to the given temperature."""
@@ -289,7 +289,7 @@ def constrain(value: float, minv: float, maxv: float) -> Union[float, int]:
289289
return max(maxv, value)
290290

291291

292-
def IMUfit( # noqa: PLR0915 pylint: disable=too-many-locals, too-many-branches, too-many-statements, too-many-arguments, too-many-positional-arguments
292+
def IMUfit( # noqa: PLR0915, N802, pylint: disable=too-many-locals, too-many-branches, too-many-statements, too-many-arguments, too-many-positional-arguments
293293
logfile: str,
294294
outfile: str,
295295
no_graph: bool,
@@ -421,17 +421,17 @@ def IMUfit( # noqa: PLR0915 pylint: disable=too-many-locals, too-many-branches,
421421
if msg_type == "TCLR" and tclr:
422422
imu = msg.I
423423

424-
T = msg.Temp
424+
temp = msg.Temp
425425
if msg.SType == 0:
426426
# accel
427427
acc = Vector3(msg.X, msg.Y, msg.Z)
428428
time = msg.TimeUS * 1.0e-6
429-
data.add_accel(imu, T, time, acc)
429+
data.add_accel(imu, temp, time, acc)
430430
elif msg.SType == 1:
431431
# gyro
432432
gyr = Vector3(msg.X, msg.Y, msg.Z)
433433
time = msg.TimeUS * 1.0e-6
434-
data.add_gyro(imu, T, time, gyr)
434+
data.add_gyro(imu, temp, time, gyr)
435435
continue
436436

437437
if msg_type == "IMU" and not tclr:
@@ -440,7 +440,7 @@ def IMUfit( # noqa: PLR0915 pylint: disable=too-many-locals, too-many-branches,
440440
if stop_capture[imu]:
441441
continue
442442

443-
T = msg.T
443+
temp = msg.T
444444
acc = Vector3(msg.AccX, msg.AccY, msg.AccZ)
445445
gyr = Vector3(msg.GyrX, msg.GyrY, msg.GyrZ)
446446

@@ -453,12 +453,12 @@ def IMUfit( # noqa: PLR0915 pylint: disable=too-many-locals, too-many-branches,
453453
sys.exit(1)
454454

455455
if c.enable[imu] == 1:
456-
acc -= c.correction_accel(imu, T)
457-
gyr -= c.correction_gyro(imu, T)
456+
acc -= c.correction_accel(imu, temp)
457+
gyr -= c.correction_gyro(imu, temp)
458458

459459
time = msg.TimeUS * 1.0e-6
460-
data.add_accel(imu, T, time, acc)
461-
data.add_gyro(imu, T, time, gyr)
460+
data.add_accel(imu, temp, time, acc)
461+
data.add_gyro(imu, temp, time, gyr)
462462

463463
if len(data.IMUs()) == 0:
464464
print("No data found")
@@ -470,7 +470,7 @@ def IMUfit( # noqa: PLR0915 pylint: disable=too-many-locals, too-many-branches,
470470
progress_callback(210)
471471
if not tclr:
472472
# apply moving average filter with 2s width
473-
data.Filter(2)
473+
data.filter(2)
474474

475475
c, clog = generate_calibration_file(outfile, online, progress_callback, data, c)
476476

pyproject.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,6 @@ lint.ignore = [
146146
"PLR0912", # too many branches
147147
"PLR0913", # too many arguments
148148
"PLR2004", # Magic value used in comparison, consider replacing `X` with a constant variable
149-
"N802", # Function name `X` should be lowercase
150-
"N806", # Variable name `X` should be lowercase
151-
"N812", # Lowercase `x` imported as non-lowercase `X`
152-
"N814", # Camelcase `X` imported as constant `Y`
153-
"N817", # CamelCase `X` imported as acronym `Y`
154149
"N999", # Invalid module name: 'MethodicConfigurator'
155150
"ISC001", # to let formatter run
156151
"ANN002",

unittests/annotate_params_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from xml.etree import ElementTree as ET # no parsing, just data-structure manipulation
2222

2323
import requests # type: ignore[import-untyped]
24-
from defusedxml import ElementTree as DET # just parsing, no data-structure manipulation
24+
from defusedxml import ElementTree as DET # noqa: N814, just parsing, no data-structure manipulation
2525

2626
from MethodicConfigurator.annotate_params import (
2727
BASE_URL,

unittests/extract_param_defaults_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def test_output_params_qgcs_2_4(self, mock_print) -> None:
258258
mock_print.assert_has_calls(expected_calls, any_order=False)
259259

260260
@patch("builtins.print")
261-
def test_output_params_qgcs_SYSID_THISMAV(self, mock_print) -> None: # pylint: disable=invalid-name
261+
def test_output_params_qgcs_SYSID_THISMAV(self, mock_print) -> None: # noqa: N802, pylint: disable=invalid-name
262262
# Prepare a dummy defaults dictionary
263263
defaults = {"PARAM2": 2.0, "PARAM1": 1.0, "SYSID_THISMAV": 3.0}
264264

@@ -276,7 +276,7 @@ def test_output_params_qgcs_SYSID_THISMAV(self, mock_print) -> None: # pylint:
276276
mock_print.assert_has_calls(expected_calls, any_order=False)
277277

278278
@patch("builtins.print")
279-
def test_output_params_qgcs_SYSID_INVALID(self, _mock_print) -> None: # pylint: disable=invalid-name
279+
def test_output_params_qgcs_SYSID_INVALID(self, _mock_print) -> None: # noqa: N802, pylint: disable=invalid-name
280280
# Prepare a dummy defaults dictionary
281281
defaults = {"PARAM2": 2.0, "PARAM1": 1.0, "SYSID_THISMAV": -1.0}
282282

@@ -293,7 +293,7 @@ def test_output_params_qgcs_SYSID_INVALID(self, _mock_print) -> None: # pylint:
293293
self.assertEqual(str(cm.exception), f"Invalid system ID parameter 16777218 must be smaller than {MAVLINK_SYSID_MAX}")
294294

295295
@patch("builtins.print")
296-
def test_output_params_qgcs_COMPID_INVALID(self, _mock_print) -> None: # pylint: disable=invalid-name
296+
def test_output_params_qgcs_COMPID_INVALID(self, _mock_print) -> None: # noqa: N802, pylint: disable=invalid-name
297297
# Prepare a dummy defaults dictionary
298298
defaults = {"PARAM2": 2.0, "PARAM1": 1.0}
299299

0 commit comments

Comments
 (0)