fix: allow_dynoption in identifiers()

This commit is contained in:
egarette@silique.fr 2025-10-15 09:39:22 +02:00
parent acca0bc040
commit 60e259fef2
2 changed files with 9 additions and 1 deletions

View file

@ -515,6 +515,12 @@ def test_dyndescription_subdyn():
assert cfg.option('od.dod2val1.dodval1.st').type() == "string"
assert cfg.option('od.dod2.dod').type() == "optiondescription"
assert cfg.option('od.dod2val1.dodval1').type() == "optiondescription"
#
with pytest.raises(AttributeOptionError):
cfg.option('od.dod2.dod').identifiers()
assert cfg.option('od.dod2.dod').identifiers(only_self=True) == ['val1', 'val2']
assert cfg.option('od.dod2val1.dodval1').identifiers() == ['val1', 'val1']
assert cfg.option('od.dod2val1.dodval1').identifiers(only_self=True) == ['val1', 'val2']
def test_callback_dyndescription_subdyn():

View file

@ -521,7 +521,7 @@ class _TiramisuOptionOptionDescription:
)
return ret
@option_type(["dynamic", "with_or_without_index"])
@option_type(["dynamic", "with_or_without_index", "allow_dynoption"])
def identifiers(
self,
only_self: bool = False,
@ -529,6 +529,8 @@ class _TiramisuOptionOptionDescription:
):
"""Get identifiers for dynamic option"""
if not only_self:
if self._subconfig.is_dynamic_without_identifiers and not uncalculated:
raise AttributeOptionError(self._subconfig.path, "option-dynamic")
return self._subconfig.identifiers
if (
not self._subconfig.option.impl_is_optiondescription()