values_params in ChoiceOption must be rebuild

This commit is contained in:
Emmanuel Garette 2018-04-15 22:59:29 +02:00
parent 54b57968bc
commit 1548099388
2 changed files with 6 additions and 4 deletions

View File

@ -173,7 +173,6 @@ class Base(object):
"""
:add_value: add value as first argument for validator
"""
is_multi = self.impl_is_dynoptiondescription() or self.impl_is_multi()
func_args, func_kwargs, func_positional, func_keyword = self._get_function_args(calculator)
calculator_args, calculator_kwargs = self._get_parameters_args(calculator_params, add_value)
@ -279,11 +278,12 @@ class Base(object):
self)
callback_params = self._build_calculator_params(callback,
callback_params)
# first part is validator
val = getattr(self, '_val_call', (None,))[0]
if callback_params == {}:
val_call = (callback,)
else:
val_call = tuple([callback, callback_params])
val_call = (callback, callback_params)
self._val_call = (val, val_call)
def impl_is_optiondescription(self):

View File

@ -60,6 +60,10 @@ class ChoiceOption(Option):
values_params,
'values',
self)
values_params = self._build_calculator_params(values,
values_params)
if values_params != {}:
self._choice_values_params = values_params
else:
if values_params is not None:
raise ValueError(_('values is not a function, so values_params must be None'))
@ -67,8 +71,6 @@ class ChoiceOption(Option):
raise TypeError(_('values must be a tuple or a function for {0}'
).format(name))
self._choice_values = values
if values_params is not None:
self._choice_values_params = values_params
super(ChoiceOption, self).__init__(name,
doc,
default=default,