diff --git a/capellambse/model/common/accessors.py b/capellambse/model/common/accessors.py index f28f9cb8d..df4719e66 100644 --- a/capellambse/model/common/accessors.py +++ b/capellambse/model/common/accessors.py @@ -1038,6 +1038,7 @@ def __init__( attr: str, *, aslist: type[element.ElementList] | None = None, + list_extra_args: cabc.Mapping[str, t.Any] | None = None, ): """Create an AttrProxyAccessor. @@ -1053,9 +1054,17 @@ def __init__( returned. If not None, must be a subclass of :class:`~capellambse.model.common.element.ElementList`. It will be used to return a list of all matched objects. + list_extra_args + Extra arguments to pass to the + :class:`~capellambse.model.common.element.ElementList` + constructor. """ del class_ - super().__init__(element.GenericElement, aslist=aslist) + super().__init__( + element.GenericElement, + aslist=aslist, + list_extra_args=list_extra_args, + ) self.attr = attr def __get__(self, obj, objtype=None): @@ -1174,9 +1183,13 @@ def __init__( *, aslist: type[element.ElementList], ) -> None: - super().__init__(class_, attr, aslist=aslist) + super().__init__( + class_, + attr, + aslist=aslist, + list_extra_args={"fixed_length": 2}, + ) assert self.aslist is not None - self.aslist.fixed_length = 2 @contextlib.contextmanager def purge_references( @@ -1847,15 +1860,19 @@ class ElementListCouplingMixin(element.ElementList[T], t.Generic[T]): """ _accessor: WritableAccessor[T] - fixed_length: t.ClassVar[int] = 0 def __init__( - self, *args: t.Any, parent: element.ModelObject, **kw: t.Any + self, + *args: t.Any, + parent: element.ModelObject, + fixed_length: int = 0, + **kw: t.Any, ) -> None: assert type(self)._accessor super().__init__(*args, **kw) self._parent = parent + self.fixed_length = fixed_length @t.overload def __setitem__(self, index: int, value: T) -> None: diff --git a/capellambse/model/crosslayer/information/datatype.py b/capellambse/model/crosslayer/information/datatype.py index a2f253a7f..7f08fb8ef 100644 --- a/capellambse/model/crosslayer/information/datatype.py +++ b/capellambse/model/crosslayer/information/datatype.py @@ -34,7 +34,11 @@ class DataType(c.GenericElement): @c.xtype_handler(None) class BooleanType(DataType): - literals = c.DirectProxyAccessor(datavalue.LiteralBooleanValue) + literals = c.DirectProxyAccessor( + datavalue.LiteralBooleanValue, + aslist=c.ElementList, + list_extra_args={"fixed_length": 2}, + ) default = c.RoleTagAccessor("ownedDefaultValue")