Skip to content

Commit 4239dca

Browse files
fix: copilot suggestions
Signed-off-by: Omkar Sarkar <omkarsarkar24@gmail.com>
1 parent b044399 commit 4239dca

4 files changed

Lines changed: 17 additions & 16 deletions

File tree

ardupilot_methodic_configurator/data_model_configuration_step.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,12 @@ def _generate_connection_renames(parameters: list[str], new_connection_prefix: s
348348
old_prefix += "_" + parts[1]
349349
new_prefix = "CAN_D" + new_number
350350
is_exception_case = True
351-
if new_type == "SERIAL" and len(parts) >= 2 and parts[0] == "BRD" and re.match(r"^SER\d+$", parts[1]):
351+
if (
352+
new_type == "SERIAL"
353+
and len(parts) >= 2
354+
and parts[0] == "BRD"
355+
and re.match(r"^SER\d+$", parts[1]) # codespell:ignore
356+
):
352357
old_prefix += "_" + parts[1]
353358
new_prefix = "BRD_SER" + new_number
354359
is_exception_case = True

ardupilot_methodic_configurator/extract_param_defaults.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
"""
55
Extracts parameter values or parameter default values from an ArduPilot .bin log file.
66
7-
Supports Mission Planner, MAVProxy and QGCS file format output
8-
97
Currently has 95% unit test coverage
108
119
SPDX-FileCopyrightText: 2024-2026 Amilcar do Carmo Lucas <amilcar.lucas@iav.de>
@@ -261,8 +259,8 @@ def extract_firmware_version_and_vehicle_type(logfile: str) -> tuple[str, int, i
261259
result = process_ver(m)
262260
if result is not None:
263261
return result
264-
continue
265-
msg_fallback_result = process_msg_version_fallback(m, msg_fallback_result)
262+
elif m.get_type() == "MSG":
263+
msg_fallback_result = process_msg_version_fallback(m, msg_fallback_result)
266264

267265
if msg_fallback_result is not None:
268266
return msg_fallback_result

ardupilot_methodic_configurator/log_analysis/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
ArduPilot log analysis module.
33
4-
Parses and analyses ArduPilot .bin log files to extract parameters,firmware information, and telemetry data.
4+
Parses and analyses ArduPilot .bin log files to extract parameters, firmware information, and telemetry data.
55
66
This file is part of ArduPilot Methodic Configurator. https://github.com/ArduPilot/MethodicConfigurator
77

ardupilot_methodic_configurator/log_analysis/backend_log_extraction.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
"""
22
Parses an ArduPilot .bin log file, and extracts all the parameters required for analysing the log.
33
4-
Supports Mission Planner, MAVProxy and QGCS file format output
5-
64
SPDX-FileCopyrightText: 2024-2026 Amilcar do Carmo Lucas <amilcar.lucas@iav.de>
75
86
SPDX-License-Identifier: GPL-3.0-or-later
@@ -43,7 +41,7 @@ def open_log(logfile: str) -> mavutil.mavfile:
4341
mlog = mavutil.mavlink_connection(logfile)
4442
except Exception as e:
4543
msg = f"Error opening the {logfile} logfile: {e!s}"
46-
raise SystemExit(msg) from e
44+
raise OSError(msg) from e
4745
return mlog # pyright: ignore[reportReturnType] # pymavlink stubs include CSVReader which doesn't extend mavfile
4846

4947

@@ -59,7 +57,7 @@ def close_log(mlog: mavutil.mavfile) -> None:
5957
mlog.close()
6058

6159

62-
class LogData:
60+
class LogData: # pylint: disable=too-few-public-methods
6361
"""Contains all data extracted from an ArduPilot .bin log."""
6462

6563
def __init__(self) -> None:
@@ -70,7 +68,7 @@ def __init__(self) -> None:
7068
self.frame_type: int | None = None
7169

7270

73-
class LogReader:
71+
class LogReader: # pylint: disable=too-few-public-methods
7472
"""Reader for Ardupilot log files, sending each message to its appropriate function."""
7573

7674
def __init__(self, logfile: str) -> None:
@@ -131,7 +129,7 @@ def process_param(msg: mavutil.mavfile, log_data: LogData) -> None:
131129
default_params and current_params from the message's Default and Value fields.
132130
133131
Args:
134-
msg: A parsed MAVLink message.
132+
msg: A PARM log entry parsed from an ArduPilot .bin file.
135133
log_data: The LogData instance to write param value into.
136134
137135
"""
@@ -152,10 +150,10 @@ def process_param(msg: mavutil.mavfile, log_data: LogData) -> None:
152150

153151
def process_ver(msg: mavutil.mavfile) -> tuple[str, int, int, int] | None:
154152
"""
155-
Extract firmware version form VER message.
153+
Extract firmware version from VER message.
156154
157155
Args:
158-
msg: A parsed MAVLink message.
156+
msg: A VER log entry parsed from an ArduPilot .bin file.
159157
160158
Returns:
161159
A tuple of (vehicle_type, major, minor, patch), e.g. ("ArduCopter", 4, 6, 3).
@@ -174,13 +172,13 @@ def process_msg_version_fallback(
174172
msg: mavutil.mavfile, firmware_from_msg: tuple[str, int, int, int] | None
175173
) -> tuple[str, int, int, int] | None:
176174
"""
177-
Extract firmware version form MSG message.
175+
Extract firmware version from MSG message.
178176
179177
Falls back to scanning MSG messages until one with a parseable "Vx.y" version
180178
is found (e.g. "ArduCopter V4.6.3 (hash)").
181179
182180
Args:
183-
msg: A parsed MAVLink message.
181+
msg: A MSG log entry parsed from an ArduPilot .bin file.
184182
firmware_from_msg: If any previously found message from MSG, or None.
185183
186184
Returns:

0 commit comments

Comments
 (0)