Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,7 @@ def _update_possible_choices_for_path( # pylint: disable=too-many-branches
batt_available_protocols: list[str] = []
for conn_dict in BATT_MONITOR_CONNECTION.values():
conn_type = conn_dict["type"]
# Handle both list and direct port type references
if isinstance(conn_type, list):
if value in conn_type:
batt_available_protocols.append(str(conn_dict["protocol"]))
elif value in conn_type:
# conn_type is a reference to a port list (e.g., ANALOG_PORTS, I2C_PORTS)
if isinstance(conn_type, list) and value in conn_type:
batt_available_protocols.append(str(conn_dict["protocol"]))

self._possible_choices[protocol_path] = (
Expand Down Expand Up @@ -421,19 +416,34 @@ def _update_possible_choices_for_path( # pylint: disable=too-many-branches
gnss_available_protocols: list[str] = []
for conn_dict in GNSS_RECEIVER_CONNECTION.values():
conn_type = conn_dict["type"]
# Handle both list and direct port type references
if isinstance(conn_type, list):
if value in conn_type:
gnss_available_protocols.append(str(conn_dict["protocol"]))
elif value in conn_type:
# conn_type is a reference to a port list (e.g., SERIAL_PORTS, CAN_PORTS)
if isinstance(conn_type, list) and value in conn_type:
gnss_available_protocols.append(str(conn_dict["protocol"]))

self._possible_choices[protocol_path] = (
tuple(gnss_available_protocols) if gnss_available_protocols else ("None",)
)

def validate_entry_limits(self, value: str, path: ComponentPath) -> tuple[str, Optional[float]]: # noqa: PLR0911 # pylint: disable=too-many-return-statements
def _validate_tow_limits(self, value: str, path: ComponentPath) -> tuple[str, Optional[float]]:
"""Validate takeoff weight min/max cross-constraints."""
if path[2] == "TOW max Kg":
try:
tow_max = float(value)
except ValueError:
return _("Takeoff Weight max must be a float"), None
lim = self.get_component_value(("Frame", "Specifications", "TOW min Kg"))
if lim:
return self.validate_against_another_value(tow_max, lim, "TOW min Kg", above=True, delta=0.01)
if path[2] == "TOW min Kg":
try:
tow_min = float(value)
except ValueError:
return _("Takeoff Weight min must be a float"), None
lim = self.get_component_value(("Frame", "Specifications", "TOW max Kg"))
if lim:
return self.validate_against_another_value(tow_min, lim, "TOW max Kg", above=False, delta=0.01)
return "", None

def validate_entry_limits(self, value: str, path: ComponentPath) -> tuple[str, Optional[float]]:

Copilot AI Apr 9, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validate_entry_limits still contains many early returns (e.g., type conversion errors, range checks, TOW min/max cross-validation, and delegation to validate_cell_voltage). Since Ruff is configured to lint PLR rules (including PLR0911 too-many-return-statements), removing the previous # noqa: PLR0911 / pylint disable will likely make this file fail linting. Consider re-adding the suppression for this function or refactoring to reduce the number of return statements (e.g., accumulate an (error, corrected) result and return once).

Suggested change
def validate_entry_limits(self, value: str, path: ComponentPath) -> tuple[str, Optional[float]]:
def validate_entry_limits( # noqa: PLR0911 # pylint: disable=too-many-return-statements
self, value: str, path: ComponentPath
) -> tuple[str, Optional[float]]:

Copilot uses AI. Check for mistakes.
"""
Validate entry values against limits.

Expand All @@ -455,23 +465,7 @@ def validate_entry_limits(self, value: str, path: ComponentPath) -> tuple[str, O

# Validate takeoff weight limits
if path[0] == "Frame" and path[1] == "Specifications" and "TOW" in path[2]:
if path[2] == "TOW max Kg":
try:
tow_max = float(value)
except ValueError:
return _("Takeoff Weight max must be a float"), None
lim = self.get_component_value(("Frame", "Specifications", "TOW min Kg"))
if lim:
return self.validate_against_another_value(tow_max, lim, "TOW min Kg", above=True, delta=0.01)

if path[2] == "TOW min Kg":
try:
tow_min = float(value)
except ValueError:
return _("Takeoff Weight min must be a float"), None
lim = self.get_component_value(("Frame", "Specifications", "TOW max Kg"))
if lim:
return self.validate_against_another_value(tow_min, lim, "TOW max Kg", above=False, delta=0.01)
return self._validate_tow_limits(value, path)

if path in BATTERY_CELL_VOLTAGE_PATHS:
return self.validate_cell_voltage(value, path)
Expand Down Expand Up @@ -569,7 +563,7 @@ def validate_against_another_value( # pylint: disable=too-many-arguments,too-ma
), corrected
return "", None # value is within valid interval, return empty string as there is no error

def validate_all_data(self, entry_values: dict[ComponentPath, str]) -> tuple[bool, list[str]]: # pylint: disable=too-many-branches
def validate_all_data(self, entry_values: dict[ComponentPath, str]) -> tuple[bool, list[str]]:
"""
Centralize all data validation logic.

Expand Down Expand Up @@ -598,20 +592,9 @@ def validate_all_data(self, entry_values: dict[ComponentPath, str]) -> tuple[boo
# Check for duplicate connections
if len(path) >= 3 and path[1] == "FC Connection" and path[2] == "Type":
if value in fc_serial_connection and value not in {"CAN1", "CAN2", "I2C1", "I2C2", "I2C3", "I2C4", "None"}:
battery_monitor_protocol = entry_values.get(
("Battery Monitor", "FC Connection", "Protocol"),
self.get_component_value(("Battery Monitor", "FC Connection", "Protocol")),
)

# Allow certain combinations
if path[0] in {"Telemetry", "RC Receiver"} and fc_serial_connection[value] in {"Telemetry", "RC Receiver"}:
continue
if (
battery_monitor_protocol == "ESC"
and path[0] in {"Battery Monitor", "ESC"}
and fc_serial_connection[value] in {"Battery Monitor", "ESC"}
):
continue

error_msg = _("Duplicate FC connection type '{value}' for {paths_str}")
errors.append(error_msg.format(value=value, paths_str=paths_str))
Expand Down
9 changes: 7 additions & 2 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [],
"extends": ["config:best-practices", ":semanticCommits"],
"enabledManagers": ["pre-commit", "custom.regex"],
"repositories": ["ArduPilot/MethodicConfigurator"],
"platform": "github",
Expand All @@ -21,6 +21,7 @@
{
"matchManagers": ["pre-commit"],
"automerge": true,
"minimumReleaseAge": "14 days",
"pinDigests": true,
"rangeStrategy": "pin"
},
Expand All @@ -45,7 +46,11 @@
}
],
"pin": {"enabled": true},
"dependencyDashboard": false,
"dependencyDashboard": true,
"osvVulnerabilityAlerts": true,
"vulnerabilityAlerts": {
"enabled": true
},
"ignorePaths": ["**/node_modules/**", "**/bower_components/**", "**/.git/**"],
"customManagers": [
{
Expand Down
Loading