do not validate 'warnings' in make_dict
This commit is contained in:
parent
f6e963ae38
commit
7a4a22f52d
|
@ -156,9 +156,9 @@ class CommonTiramisuOption(CommonTiramisu):
|
|||
option = self.option_bag.option
|
||||
if not option.impl_is_optiondescription():
|
||||
if self.option_bag.index is None and option.impl_is_master_slaves('slave'):
|
||||
raise APIError('index must be set with a slave option')
|
||||
raise APIError(_('index must be set with the slave option "{}"').format(self.option_bag.path))
|
||||
elif self.option_bag.index is not None and not option.impl_is_master_slaves('slave'):
|
||||
raise APIError('index must be set only with a slave option')
|
||||
raise APIError(_('index must be set only with a slave option, not for "{}"').format(self.option_bag.path))
|
||||
|
||||
def __getattr__(self, name):
|
||||
if not hasattr(CommonTiramisuOption, name):
|
||||
|
@ -350,6 +350,7 @@ class TiramisuOptionPermissive(CommonTiramisuOption):
|
|||
allow_optiondescription = True
|
||||
slave_need_index = False
|
||||
|
||||
# FIXME should have same api than property
|
||||
def __init__(self,
|
||||
name: str,
|
||||
subconfig: Union[KernelConfig, SubConfig],
|
||||
|
@ -533,7 +534,7 @@ class TiramisuOption(CommonTiramisu):
|
|||
|
||||
def _find(self,
|
||||
name: str,
|
||||
value: Union[bool, Undefined]=undefined,
|
||||
value=undefined,
|
||||
type=None,
|
||||
first: bool=False):
|
||||
"""find an option by name (only for optiondescription)"""
|
||||
|
@ -849,7 +850,9 @@ class TiramisuContextOption(TiramisuContext):
|
|||
withoption=None,
|
||||
fullpath=False):
|
||||
"""return dict with path as key and value"""
|
||||
return self.config_bag.context.make_dict(self.config_bag,
|
||||
config_bag = self.config_bag.copy()
|
||||
config_bag._setting_properties = self.config_bag.setting_properties - {'warnings'}
|
||||
return config_bag.context.make_dict(config_bag,
|
||||
flatten=flatten,
|
||||
fullpath=fullpath,
|
||||
withoption=withoption,
|
||||
|
|
|
@ -181,7 +181,7 @@ class ConfigBag:
|
|||
return 'validator' in self._setting_properties
|
||||
return self._validate
|
||||
if key == 'setting_properties':
|
||||
if self.force_unrestraint:
|
||||
if self.force_unrestraint or not self._validate:
|
||||
return None
|
||||
return self._setting_properties
|
||||
if key == '_setting_properties':
|
||||
|
@ -195,10 +195,6 @@ class ConfigBag:
|
|||
|
||||
def __setattr__(self, key, value):
|
||||
if key == 'validate':
|
||||
try:
|
||||
del self._setting_properties
|
||||
except AttributeError:
|
||||
pass
|
||||
self._validate = value
|
||||
else:
|
||||
super().__setattr__(key, value)
|
||||
|
@ -208,8 +204,11 @@ class ConfigBag:
|
|||
for key in self.__slots__:
|
||||
if key == 'fromconsistency' and self.fromconsistency != []:
|
||||
kwargs['fromconsistency'] = copy(self.fromconsistency)
|
||||
value = getattr(self, key)
|
||||
if key == '_validate' and value == True:
|
||||
pass
|
||||
else:
|
||||
kwargs[key] = getattr(self, key)
|
||||
kwargs[key] = value
|
||||
return ConfigBag(**kwargs)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue