From 29282d8ea36b4b8962a5260c42fd924992a60e5e Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Thu, 18 Mar 2021 08:57:22 +0100 Subject: [PATCH] calculation with submulti --- tiramisu/option/leadership.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tiramisu/option/leadership.py b/tiramisu/option/leadership.py index baddcc2..c36824f 100644 --- a/tiramisu/option/leadership.py +++ b/tiramisu/option/leadership.py @@ -69,11 +69,21 @@ class Leadership(OptionDescription): child.impl_get_display_name())) if idx != 0: default = child.impl_getdefault() - if default != [] and not isinstance(default, Calculation): - raise ValueError(_('not allowed default value for follower option "{0}" ' - 'in leadership "{1}"' - '').format(child.impl_get_display_name(), - self.impl_get_display_name())) + if default != []: + if child.impl_is_submulti() and isinstance(default, tuple): + for val in default: + if not isinstance(val, Calculation): + calculation = False + else: + # empty default is valid + calculation = True + else: + calculation = isinstance(default, Calculation) + if not calculation: + raise ValueError(_('not allowed default value for follower option "{0}" ' + 'in leadership "{1}"' + '').format(child.impl_get_display_name(), + self.impl_get_display_name())) if idx != 0: # remove empty property for follower child._properties = frozenset(child._properties - {'empty', 'unique'})