From 668ed3ad3742deed93596a748b4012b0341d5b2f Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Thu, 18 Mar 2021 08:54:59 +0100 Subject: [PATCH] better error when value not in a choice --- tiramisu/error.py | 2 ++ tiramisu/option/choiceoption.py | 4 ++-- tiramisu/option/syndynoptiondescription.py | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tiramisu/error.py b/tiramisu/error.py index 0c1384d..c79a26a 100644 --- a/tiramisu/error.py +++ b/tiramisu/error.py @@ -20,6 +20,8 @@ from .i18n import _ def display_list(lst, separator='and', add_quote=False): + if not lst: + return '""' if separator == 'and': separator = _('and') elif separator == 'or': diff --git a/tiramisu/option/choiceoption.py b/tiramisu/option/choiceoption.py index 335f4f9..b971388 100644 --- a/tiramisu/option/choiceoption.py +++ b/tiramisu/option/choiceoption.py @@ -60,8 +60,8 @@ class ChoiceOption(Option): if isinstance(self._choice_values, Calculation): values = await self._choice_values.execute(option_bag) if values is not undefined and not isinstance(values, list): - raise ConfigError(_('calculated values for {0} is not a list' - '').format(self.impl_getname())) + raise ConfigError(_('the calculated values "{0}" for "{1}" is not a list' + '').format(values, self.impl_getname())) else: values = self._choice_values return values diff --git a/tiramisu/option/syndynoptiondescription.py b/tiramisu/option/syndynoptiondescription.py index f6dd507..6df1cf5 100644 --- a/tiramisu/option/syndynoptiondescription.py +++ b/tiramisu/option/syndynoptiondescription.py @@ -84,7 +84,8 @@ class SynDynOptionDescription: async def get_children(self, config_bag: ConfigBag, - dyn: bool=True): + dyn: bool=True, + ): subpath = self.impl_getpath() children = [] for child in await self._opt.get_children(config_bag):