From bcb7615412f3acec4805259363195c97bf4e0024 Mon Sep 17 00:00:00 2001 From: agonzat Date: Wed, 11 Oct 2023 21:54:12 +0200 Subject: [PATCH] Bugfixes on Python code generation (#152) * Fix raising of validation error * Fix inverse logic of 'unique' validator --- .../generate_parameter_library_py/python_convertions.py | 2 +- .../generate_parameter_library_py/python_validators.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/generate_parameter_library_py/generate_parameter_library_py/python_convertions.py b/generate_parameter_library_py/generate_parameter_library_py/python_convertions.py index 379c9c9..4790900 100644 --- a/generate_parameter_library_py/generate_parameter_library_py/python_convertions.py +++ b/generate_parameter_library_py/generate_parameter_library_py/python_convertions.py @@ -92,7 +92,7 @@ def get_func_signature(self, function_name: str, base_type: str) -> str: @typechecked def initialization_fail_validation(self, param_name: str) -> str: - return f"raise InvalidParameterValueException('Invalid value set during initialization for parameter {param_name}: ' + validation_result)" + return f"raise InvalidParameterValueException('{param_name}',param.value, 'Invalid value set during initialization for parameter {param_name}: ' + validation_result)" @typechecked def initialization_pass_validation(self, param_name: str) -> str: diff --git a/generate_parameter_library_py/generate_parameter_library_py/python_validators.py b/generate_parameter_library_py/generate_parameter_library_py/python_validators.py index 4c1097d..629a740 100644 --- a/generate_parameter_library_py/generate_parameter_library_py/python_validators.py +++ b/generate_parameter_library_py/generate_parameter_library_py/python_validators.py @@ -71,7 +71,7 @@ def one_of(param, values): # Array validators def unique(param): - if not len(set(param.value)) != len(param.value): + if len(set(param.value)) != len(param.value): return f"Parameter '{param.name}' must only contain unique values" return ""