From 4bd1b8f04ea9337de75d959f31d3ba4cb153ee4f Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Thu, 16 Oct 2025 08:10:53 +0200 Subject: [PATCH] fix: allow_dynoption --- tiramisu/api.py | 12 ++++++++---- tiramisu/config.py | 4 ++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tiramisu/api.py b/tiramisu/api.py index 4f15788..6ce56e5 100644 --- a/tiramisu/api.py +++ b/tiramisu/api.py @@ -518,7 +518,7 @@ class _TiramisuOptionOptionDescription: and self._subconfig.option.impl_is_dynoptiondescription() ) - @option_type(["option", "leadership"]) + @option_type(["option", "leadership", "allow_dynoption"]) def leader(self): """Get the leader option for a leadership or a follower option""" option = self._subconfig.option @@ -640,7 +640,7 @@ class _TiramisuOptionOption(_TiramisuOptionOptionDescription): return self._subconfig.index return TiramisuOption(self._path, index, self._config_bag) - @option_type(["symlink", "optiondescription"]) + @option_type(["symlink", "optiondescription", "allow_dynoption"]) def option(self, *args, **kwargs): """For OptionDescription get sub option, for symlinkoption get the linked option""" if self._subconfig.option.impl_is_optiondescription(): @@ -1047,13 +1047,15 @@ class TiramisuOptionValue(CommonTiramisuOption, _TiramisuODGet): return False return True - @option_type(["choice", "with_index"]) + @option_type(["choice", "with_index", "allow_dynoption"]) def list( self, *, uncalculated: bool = False, ): """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( self._subconfig, uncalculated, @@ -1215,7 +1217,7 @@ class TiramisuOption( self._set_subconfig() return self._subconfig.option.impl_get_group_type() - @option_type(["optiondescription", "validate_properties"]) + @option_type(["optiondescription", "validate_properties", "allow_dynoption"]) def list( self, *, @@ -1225,6 +1227,8 @@ class TiramisuOption( ): """List options inside an option description (by default list only option)""" self._set_subconfig() + if self._subconfig.is_dynamic_without_identifiers and not uncalculated: + raise AttributeOptionError(self._subconfig.path, "option-dynamic") return self._list( self._subconfig, validate_properties, diff --git a/tiramisu/config.py b/tiramisu/config.py index ebf05ef..8854955 100644 --- a/tiramisu/config.py +++ b/tiramisu/config.py @@ -426,6 +426,8 @@ class SubConfig: child, None, validate_properties, + allow_dynoption=uncalculated, + check_dynamic_without_identifiers=not uncalculated, ) except PropertiesOptionError as err: if err.proptype in (["mandatory"], ["empty"]): @@ -794,6 +796,8 @@ class _Config(CCache): name=name, identifier=identifier, true_path=true_path_, + allow_dynoption=allow_dynoption, + check_dynamic_without_identifiers=not allow_dynoption, ) return subconfig