better error when value not in a choice

This commit is contained in:
Emmanuel Garette 2021-03-18 08:54:59 +01:00
parent 5858bcc00b
commit b76db42204
3 changed files with 6 additions and 3 deletions

View File

@ -20,6 +20,8 @@ from .i18n import _
def display_list(lst, separator='and', add_quote=False): def display_list(lst, separator='and', add_quote=False):
if not lst:
return '""'
if separator == 'and': if separator == 'and':
separator = _('and') separator = _('and')
elif separator == 'or': elif separator == 'or':

View File

@ -60,8 +60,8 @@ class ChoiceOption(Option):
if isinstance(self._choice_values, Calculation): if isinstance(self._choice_values, Calculation):
values = await self._choice_values.execute(option_bag) values = await self._choice_values.execute(option_bag)
if values is not undefined and not isinstance(values, list): if values is not undefined and not isinstance(values, list):
raise ConfigError(_('calculated values for {0} is not a list' raise ConfigError(_('the calculated values "{0}" for "{1}" is not a list'
'').format(self.impl_getname())) '').format(values, self.impl_getname()))
else: else:
values = self._choice_values values = self._choice_values
return values return values

View File

@ -84,7 +84,8 @@ class SynDynOptionDescription:
async def get_children(self, async def get_children(self,
config_bag: ConfigBag, config_bag: ConfigBag,
dyn: bool=True): dyn: bool=True,
):
subpath = self.impl_getpath() subpath = self.impl_getpath()
children = [] children = []
for child in await self._opt.get_children(config_bag): for child in await self._opt.get_children(config_bag):