diff --git a/ardupilot_methodic_configurator/data_model_vehicle_components_validation.py b/ardupilot_methodic_configurator/data_model_vehicle_components_validation.py index 886d95052..3187515a8 100644 --- a/ardupilot_methodic_configurator/data_model_vehicle_components_validation.py +++ b/ardupilot_methodic_configurator/data_model_vehicle_components_validation.py @@ -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] = ( @@ -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]]: """ Validate entry values against limits. @@ -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) @@ -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. @@ -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)) diff --git a/renovate.json b/renovate.json index 0a1eca19a..6da1f503d 100644 --- a/renovate.json +++ b/renovate.json @@ -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", @@ -21,6 +21,7 @@ { "matchManagers": ["pre-commit"], "automerge": true, + "minimumReleaseAge": "14 days", "pinDigests": true, "rangeStrategy": "pin" }, @@ -45,7 +46,11 @@ } ], "pin": {"enabled": true}, - "dependencyDashboard": false, + "dependencyDashboard": true, + "osvVulnerabilityAlerts": true, + "vulnerabilityAlerts": { + "enabled": true + }, "ignorePaths": ["**/node_modules/**", "**/bower_components/**", "**/.git/**"], "customManagers": [ {