Skip to content

Commit c29523a

Browse files
yashhzdamilcarlucas
authored andcommitted
fix(params): mark test executable and catch float(result) conversion errors
Two follow-up fixes on top of the ConfigurationStepEvalError refactor: - Set the executable bit on tests/test_data_model_safe_evaluator.py so ruff stops failing with EXE001 (shebang present but file not executable). The file was created with a shebang matching other tests; only the git mode bit was missing. - Extend the outer except in compute_parameters to also catch ValueError and TypeError. The Par(float(result), ...) call on the non-eval path can raise either when result is a string that came from a values/Bitmask lookup but is not numerically convertible, or when the dict lookup returned an unexpected type. Without these, conversion errors escaped both try blocks and could abort the configuration-step load. SyntaxError, NameError, KeyError, and StopIteration remain for defensive coverage of the surrounding code paths. Signed-off-by: Yash Goel <yashvardhan664@gmail.com>
1 parent a4e62f5 commit c29523a

2 files changed

Lines changed: 1 addition & 1 deletion

File tree

ardupilot_methodic_configurator/backend_filesystem_configuration_steps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def log_parameter_error(
249249
destination[filename] = ParDict()
250250
change_reason = _(parameter_info["Change Reason"]) if parameter_info["Change Reason"] else ""
251251
destination[filename][parameter] = Par(float(result), change_reason)
252-
except (SyntaxError, NameError, KeyError, StopIteration) as _e:
252+
except (SyntaxError, NameError, KeyError, StopIteration, ValueError, TypeError) as _e:
253253
error_msg = _(
254254
"In file '{self.configuration_steps_filename}': '{filename}' {parameter_type} "
255255
"parameter '{parameter}' could not be computed: {_e}"

tests/test_data_model_safe_evaluator.py

100644100755
File mode changed.

0 commit comments

Comments
 (0)