Skip to content

Commit fdfdb01

Browse files
committed
fix(ruff): fix D205 and D404 exceptions
1 parent 983d97c commit fdfdb01

16 files changed

+38
-38
lines changed

ardupilot_methodic_configurator/__main__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
def create_argument_parser() -> argparse.ArgumentParser:
4949
"""
50-
This function sets up an argument parser to handle the command-line arguments for the script.
50+
Argument parser to handle the command-line arguments for the script.
5151
5252
Returns:
5353
argparse.ArgumentParser: The argument parser object.

ardupilot_methodic_configurator/annotate_params.py

+2
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ def export_to_param(formatted_params: list[str], filename_out: str) -> None:
329329
def print_out(formatted_params: list[str], name: str) -> None:
330330
"""
331331
Print out the contents of the provided list.
332+
332333
If the list is too large, print only the ones that fit on the screen and
333334
wait for user input to continue.
334335
@@ -564,6 +565,7 @@ def create_doc_dict(root: ET.Element, vehicle_type: str, max_line_length: int =
564565
def format_columns(values: dict[str, Any], max_width: int = 105, max_columns: int = 4) -> list[str]:
565566
"""
566567
Formats a dictionary of values into column-major horizontally aligned columns.
568+
567569
It uses at most max_columns columns.
568570
569571
Args:

ardupilot_methodic_configurator/backend_filesystem_program_settings.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ def create_new_vehicle_dir(new_vehicle_dir: str) -> str:
7272
@staticmethod
7373
def valid_directory_name(dir_name: str) -> bool:
7474
"""
75-
Check if a given directory name contains only alphanumeric characters, underscores, hyphens,
76-
and the OS directory separator.
75+
Check if a name contains only alphanumeric characters, underscores, hyphens and the OS directory separator.
7776
7877
This function is designed to ensure that the directory name does not contain characters that are
7978
invalid for directory names in many operating systems. It does not guarantee that the name

ardupilot_methodic_configurator/backend_filesystem_vehicle_components.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@
3131

3232

3333
class VehicleComponents:
34-
"""
35-
This class provides methods to load and save
36-
vehicle components configurations from a JSON file.
37-
"""
34+
"""Load and save vehicle components configurations from a JSON file."""
3835

3936
def __init__(self, save_component_to_system_templates: bool = False) -> None:
4037
self.vehicle_components_json_filename = "vehicle_components.json"
@@ -82,6 +79,7 @@ def load_schema(self) -> dict:
8279
def load_component_templates(self) -> dict[str, list[dict]]:
8380
"""
8481
Load component templates from both system and user templates directories.
82+
8583
User templates take precedence over system templates.
8684
8785
:return: The merged templates as a dictionary
@@ -161,6 +159,7 @@ def _load_user_templates(self) -> dict[str, list[dict]]:
161159
def save_component_templates(self, templates: dict) -> tuple[bool, str]: # pylint: disable=too-many-branches
162160
"""
163161
Save component templates.
162+
164163
For user templates: Only save templates that are user-modified or not present in system templates.
165164
For system templates: Merge with existing system templates, adding new ones.
166165
@@ -401,8 +400,9 @@ def supported_vehicles() -> tuple[str, ...]:
401400
@staticmethod
402401
def get_vehicle_components_overviews() -> dict[str, TemplateOverview]:
403402
"""
404-
Finds all subdirectories of the templates base directory containing a
405-
"vehicle_components.json" file, creates a dictionary where the keys are
403+
Finds all subdirectories of the templates base directory containing a "vehicle_components.json" file.
404+
405+
Creates a dictionary where the keys are
406406
the subdirectory names (relative to templates base directory) and the
407407
values are instances of TemplateOverview.
408408

ardupilot_methodic_configurator/backend_flightcontroller_info.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ def set_capabilities(self, capabilities: int) -> None:
126126
@staticmethod
127127
def __decode_flight_sw_version(flight_sw_version: int) -> tuple[int, int, int, str]:
128128
"""
129-
Decode 32 bit flight_sw_version mavlink parameter
129+
Decode 32 bit flight_sw_version mavlink parameter.
130+
130131
corresponds to ArduPilot encoding in GCS_MAVLINK::send_autopilot_version.
131132
"""
132133
fw_type_id = (flight_sw_version >> 0) % 256 # E221, E222
@@ -151,6 +152,7 @@ def __decode_flight_sw_version(flight_sw_version: int) -> tuple[int, int, int, s
151152
def __decode_flight_capabilities(capabilities: int) -> dict[str, str]:
152153
"""
153154
Decode 32 bit flight controller capabilities bitmask mavlink parameter.
155+
154156
Returns a dict of concise English descriptions of each active capability.
155157
"""
156158
capabilities_dict: dict[str, str] = {}

ardupilot_methodic_configurator/battery_cell_voltages.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959

6060
class BatteryCell:
6161
"""
62-
This class provides methods to work with battery cell voltages for different chemistries.
62+
Battery cell voltages for different chemistries.
6363
6464
It includes methods to get the tuple of chemistries, limit voltages based on chemistry type,
6565
and get recommended voltages for a given chemistry.

ardupilot_methodic_configurator/frontend_tkinter_component_editor.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,7 @@ def __init__(self, event_type: tk.EventType) -> None:
218218

219219

220220
class ComponentEditorWindow(ComponentEditorWindowBase):
221-
"""
222-
This class validates the user input and handles user interactions
223-
for editing component configurations in the ArduPilot Methodic Configurator.
224-
"""
221+
"""Validates the user input and handles user interactions for editing component configurations."""
225222

226223
def __init__(self, version: str, local_filesystem: LocalFilesystem) -> None:
227224
self.serial_ports = ["SERIAL1", "SERIAL2", "SERIAL3", "SERIAL4", "SERIAL5", "SERIAL6", "SERIAL7", "SERIAL8"]

ardupilot_methodic_configurator/frontend_tkinter_directory_selection.py

+1
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ def get_selected_directory(self) -> str:
144144
class VehicleDirectorySelectionWidgets(DirectorySelectionWidgets):
145145
"""
146146
A subclass of DirectorySelectionWidgets specifically tailored for selecting vehicle directories.
147+
147148
This class extends the functionality of DirectorySelectionWidgets to handle vehicle-specific
148149
directory selections. It includes additional logic for updating the local filesystem with the
149150
selected vehicle directory and re-initializing the filesystem with the new directory.

ardupilot_methodic_configurator/frontend_tkinter_pair_tuple_combobox.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
# https://dev.to/geraldew/python-tkinter-an-exercise-in-wrapping-the-combobox-ndb
3838
class PairTupleCombobox(ttk.Combobox): # pylint: disable=too-many-ancestors
3939
"""
40-
A custom Combobox widget that allows for the display of a list of tuples, where each tuple contains a key and a value.
40+
A custom Combobox widget that displays a list of key-value tuples.
41+
4142
This widget processes the list of tuples to separate keys and values for display purposes and allows for the selection
4243
of a tuple based on its key.
4344
"""

ardupilot_methodic_configurator/frontend_tkinter_parameter_editor.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ def show_about_window(root: ttk.Frame, _version: str) -> None: # pylint: disabl
127127

128128
class ParameterEditorWindow(BaseWindow): # pylint: disable=too-many-instance-attributes
129129
"""
130-
This class is responsible for creating and managing the graphical user interface (GUI)
131-
for the ArduPilot methodic configurator. It inherits from the BaseWindow class
132-
and provides functionalities for displaying and interacting with drone
133-
parameters, documentation, and flight controller connection settings.
130+
Parameter editor and upload graphical user interface (GUI) window.
131+
132+
It inherits from the BaseWindow class and displays documentation and edit widgets to
133+
operate on drone parameters.
134134
"""
135135

136136
def __init__(self, current_file: str, flight_controller: FlightController, local_filesystem: LocalFilesystem) -> None:

ardupilot_methodic_configurator/param_pid_adjustment_update.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ def create_argument_parser() -> argparse.ArgumentParser:
7373

7474
def ranged_type(value_type: type, min_value: float, max_value: float) -> Callable:
7575
"""
76-
Return function handle of an argument type function for ArgumentParser checking a range:
76+
Returns a function handle to check an ArgumentParser argument range.
77+
78+
An argument type function for ArgumentParser checking a range:
7779
min_value <= arg <= max_value
7880
Args:
7981
value_type - value-type to convert arg to

ardupilot_methodic_configurator/tempcal_imu.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,7 @@ def correction(self, coeff: dict, imu: int, temperature: float, axis: str, cal_t
119119
return poly(cal_temp - TEMP_REF) - poly(temperature - TEMP_REF) # type: ignore[no-any-return]
120120

121121
def correction_accel(self, imu: int, temperature: float) -> Vector3:
122-
"""
123-
Calculate accel correction from temperature calibration from
124-
log data using parameters.
125-
"""
122+
"""Calculate accel correction from temperature calibration from log data using parameters."""
126123
cal_temp = self.atcal.get(imu, TEMP_REF)
127124
return Vector3(
128125
self.correction(self.acoef[imu], imu, temperature, "X", cal_temp),
@@ -131,10 +128,7 @@ def correction_accel(self, imu: int, temperature: float) -> Vector3:
131128
)
132129

133130
def correction_gyro(self, imu: int, temperature: float) -> Vector3:
134-
"""
135-
Calculate gyro correction from temperature calibration from
136-
log data using parameters.
137-
"""
131+
"""Calculate gyro correction from temperature calibration from log data using parameters."""
138132
cal_temp = self.gtcal.get(imu, TEMP_REF)
139133
return Vector3(
140134
self.correction(self.gcoef[imu], imu, temperature, "X", cal_temp),

param_reorder.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/python3
22

33
"""
4-
Inserts and/or removes parameter files in the configuration sequence defined in the configuration_steps_ArduCopter.json file.
4+
Inserts and/or removes parameter files in the configuration sequence defined in the configuration_steps_ArduCopter.json.
55
66
It also replaces all occurrences of the old names with the new names
77
in all *.py and *.md files in the current directory.

pyproject.toml

+6-8
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ lint.select = [
127127
"N", # pep8-naming
128128
"D", # pydocstyle
129129
"UP", # pyupgrade
130+
#"ERA", # eradicate
130131
"YTT", # flake8-2020
131132
"ANN", # flake8-annotations
132133
"ASYNC",# flake8-async
@@ -141,6 +142,7 @@ lint.select = [
141142
"T10", # flake8-debugger
142143
"EM", # flake8-errmsg
143144
"EXE", # flake8-executable
145+
#"FIX", # flake8-fixme
144146
"ISC", # flake8-implicit-str-concat
145147
"ICN", # flake8-import-conventions
146148
"LOG", # flake8-logging
@@ -154,20 +156,18 @@ lint.select = [
154156
"RSE", # flake8-raise (RSE)
155157
"RET", # flake8-return (RET)
156158
"SLF", # flake8-self (SLF)
157-
"SLOT", # flake8-slots (SLOT)
158159
"SIM", # flake8-simplify
160+
"SLOT", # flake8-slots (SLOT)
159161
"TID", # flake8-tidy-imports
162+
#"TD", # flake8-todos
160163
"TC", # flake8-type-checking
161-
"INT", # flake8-gettext
162164
"ARG", # flake8-unused-arguments
163165
#"PTH", # flake8-use-pathlib
164-
#"TD", # flake8-todos
165-
#"FIX", # flake8-fixme
166-
#"ERA", # eradicate
166+
"INT", # flake8-gettext
167167
"PD", # pandas-vet
168168
"PGH", # pygrep-hooks
169169
"PL", # Pylint
170-
"FLY002", # flynt
170+
"FLY", # flynt
171171
"PERF", # Performance-related issues
172172
"FURB", # refurb
173173
"DOC", # pydoclint
@@ -185,9 +185,7 @@ lint.ignore = [
185185
"D103", # Missing docstring in public function
186186
"D107", # Missing docstring in `__init__`
187187
"D203", #
188-
"D205", # 1 blank line required between summary line and description
189188
"D212", # Multi-line docstring summary should start at the first line
190-
"D404", # First word of the docstring should not be "This"
191189
"D401", # First line of docstring should be in imperative mood
192190
"COM812",
193191
"DTZ005", # `tz=None` passed to `datetime.datetime.now()`

tests/test_configuration_steps_schema.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env python3
22

33
"""
4+
Validates all configuration_steps_*.json files against a JSON schema.
5+
46
Finds all configuration_steps_*.json files in the project and its subdirectories, and validates them
57
against the JSON schema defined in "ardupilot_methodic_configurator/configuration_steps_schema.json".
68

tests/test_vehicle_components_schema.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env python3
22

33
"""
4+
Validates all vehicle_components.json files against a JSON schema.
5+
46
Finds all vehicle_components.json files in the project and its subdirectories, and validates them
57
against the JSON schema defined in "ardupilot_methodic_configurator/vehicle_components_schema.json".
68

0 commit comments

Comments
 (0)