From 9731769694110e770db26413821b4d368c967347 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Sat, 1 Oct 2022 19:44:23 +0200 Subject: [PATCH] better is_not_unique support --- tiramisu/option/option.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tiramisu/option/option.py b/tiramisu/option/option.py index 6117e2d..6bc1873 100644 --- a/tiramisu/option/option.py +++ b/tiramisu/option/option.py @@ -28,7 +28,7 @@ from .baseoption import BaseOption, submulti, STATIC_TUPLE from ..i18n import _ from ..setting import undefined, OptionBag, Undefined from ..autolib import Calculation, Params, ParamOption, ParamInformation, ParamSelfInformation -from ..error import (ConfigError, ValueWarning, ValueErrorWarning, PropertiesOptionError, +from ..error import (ConfigError, ValueWarning, ValueErrorWarning, ValueOptionError, display_list) from .syndynoption import SynDynOption #ALLOWED_CONST_LIST = ['_cons_not_equal'] @@ -347,14 +347,17 @@ class Option(BaseOption): def _is_not_unique(value, option_bag): # if set(value) has not same length than value - if config_bag is not undefined and check_error and \ - 'unique' in option_bag.properties: - lvalue = [val for val in value if val is not None] - if len(set(lvalue)) != len(lvalue): - for idx, val in enumerate(value): - if val in value[idx+1:]: - raise ValueError(_('the value "{}" is not unique' - '').format(val)) + if config_bag is undefined or not check_error or \ + 'unique' not in option_bag.properties: + return + lvalue = [val for val in value if val is not None] + if len(set(lvalue)) == len(lvalue): + return + for idx, val in enumerate(value): + if val not in value[idx+1:]: + continue + raise ValueError(_('the value "{}" is not unique' + '').format(val)) async def calculation_validator(val, _index):