fix: allow_dynoption

This commit is contained in:
egarette@silique.fr 2025-10-16 08:10:53 +02:00
parent 6f2f479364
commit 4bd1b8f04e
2 changed files with 12 additions and 4 deletions

View file

@ -518,7 +518,7 @@ class _TiramisuOptionOptionDescription:
and self._subconfig.option.impl_is_dynoptiondescription() and self._subconfig.option.impl_is_dynoptiondescription()
) )
@option_type(["option", "leadership"]) @option_type(["option", "leadership", "allow_dynoption"])
def leader(self): def leader(self):
"""Get the leader option for a leadership or a follower option""" """Get the leader option for a leadership or a follower option"""
option = self._subconfig.option option = self._subconfig.option
@ -640,7 +640,7 @@ class _TiramisuOptionOption(_TiramisuOptionOptionDescription):
return self._subconfig.index return self._subconfig.index
return TiramisuOption(self._path, index, self._config_bag) return TiramisuOption(self._path, index, self._config_bag)
@option_type(["symlink", "optiondescription"]) @option_type(["symlink", "optiondescription", "allow_dynoption"])
def option(self, *args, **kwargs): def option(self, *args, **kwargs):
"""For OptionDescription get sub option, for symlinkoption get the linked option""" """For OptionDescription get sub option, for symlinkoption get the linked option"""
if self._subconfig.option.impl_is_optiondescription(): if self._subconfig.option.impl_is_optiondescription():
@ -1047,13 +1047,15 @@ class TiramisuOptionValue(CommonTiramisuOption, _TiramisuODGet):
return False return False
return True return True
@option_type(["choice", "with_index"]) @option_type(["choice", "with_index", "allow_dynoption"])
def list( def list(
self, self,
*, *,
uncalculated: bool = False, uncalculated: bool = False,
): ):
"""All values available for a ChoiceOption""" """All values available for a ChoiceOption"""
if self._subconfig.is_dynamic_without_identifiers and not uncalculated:
raise AttributeOptionError(self._subconfig.path, "option-dynamic")
return self._subconfig.option.impl_get_values( return self._subconfig.option.impl_get_values(
self._subconfig, self._subconfig,
uncalculated, uncalculated,
@ -1215,7 +1217,7 @@ class TiramisuOption(
self._set_subconfig() self._set_subconfig()
return self._subconfig.option.impl_get_group_type() return self._subconfig.option.impl_get_group_type()
@option_type(["optiondescription", "validate_properties"]) @option_type(["optiondescription", "validate_properties", "allow_dynoption"])
def list( def list(
self, self,
*, *,
@ -1225,6 +1227,8 @@ class TiramisuOption(
): ):
"""List options inside an option description (by default list only option)""" """List options inside an option description (by default list only option)"""
self._set_subconfig() self._set_subconfig()
if self._subconfig.is_dynamic_without_identifiers and not uncalculated:
raise AttributeOptionError(self._subconfig.path, "option-dynamic")
return self._list( return self._list(
self._subconfig, self._subconfig,
validate_properties, validate_properties,

View file

@ -426,6 +426,8 @@ class SubConfig:
child, child,
None, None,
validate_properties, validate_properties,
allow_dynoption=uncalculated,
check_dynamic_without_identifiers=not uncalculated,
) )
except PropertiesOptionError as err: except PropertiesOptionError as err:
if err.proptype in (["mandatory"], ["empty"]): if err.proptype in (["mandatory"], ["empty"]):
@ -794,6 +796,8 @@ class _Config(CCache):
name=name, name=name,
identifier=identifier, identifier=identifier,
true_path=true_path_, true_path=true_path_,
allow_dynoption=allow_dynoption,
check_dynamic_without_identifiers=not allow_dynoption,
) )
return subconfig return subconfig