diff --git a/basyx/aas/model/aas.py b/basyx/aas/model/aas.py index 943f1e25e..09740034c 100644 --- a/basyx/aas/model/aas.py +++ b/basyx/aas/model/aas.py @@ -73,10 +73,12 @@ def _check_constraint_del_spec_asset_id(self, _item_to_del: base.SpecificAssetId raise base.AASConstraintViolation( 131, "An AssetInformation has to have a globalAssetId or a specificAssetId") - def _get_global_asset_id(self): + @property + def global_asset_id(self): return self._global_asset_id - def _set_global_asset_id(self, global_asset_id: Optional[base.Identifier]): + @global_asset_id.setter + def global_asset_id(self, global_asset_id: Optional[base.Identifier]): if global_asset_id is None: if self.specific_asset_id is None or not self.specific_asset_id: raise base.AASConstraintViolation( @@ -85,8 +87,6 @@ def _set_global_asset_id(self, global_asset_id: Optional[base.Identifier]): _string_constraints.check_identifier(global_asset_id) self._global_asset_id = global_asset_id - global_asset_id = property(_get_global_asset_id, _set_global_asset_id) - def __repr__(self) -> str: return "AssetInformation(assetKind={}, globalAssetId={}, specificAssetId={}, assetType={}, " \ "defaultThumbnail={})".format(self.asset_kind, self._global_asset_id, str(self.specific_asset_id), diff --git a/basyx/aas/model/base.py b/basyx/aas/model/base.py index e96bf4a1d..e835c3262 100644 --- a/basyx/aas/model/base.py +++ b/basyx/aas/model/base.py @@ -599,7 +599,7 @@ class Referable(HasExtension, metaclass=abc.ABCMeta): Default is an empty string, making it use the source of its ancestor, if possible. """ @abc.abstractmethod - def __init__(self): + def __init__(self) -> None: super().__init__() self._id_short: Optional[NameType] = None self.display_name: Optional[MultiLanguageNameType] = dict() @@ -1258,7 +1258,7 @@ class Identifiable(Referable, metaclass=abc.ABCMeta): :ivar ~.id: The globally unique id of the element. """ @abc.abstractmethod - def __init__(self): + def __init__(self) -> None: super().__init__() self.administration: Optional[AdministrativeInformation] = None # The id attribute is set by all inheriting classes __init__ functions. @@ -1516,7 +1516,7 @@ class HasKind(metaclass=abc.ABCMeta): :ivar _kind: Kind of the element: either type or instance. Default = :attr:`~ModellingKind.INSTANCE`. """ @abc.abstractmethod - def __init__(self): + def __init__(self) -> None: super().__init__() self._kind: ModellingKind = ModellingKind.INSTANCE @@ -1537,7 +1537,7 @@ class Qualifiable(Namespace, metaclass=abc.ABCMeta): qualifiable element. """ @abc.abstractmethod - def __init__(self): + def __init__(self) -> None: super().__init__() self.namespace_element_sets: List[NamespaceSet] = [] self.qualifier: NamespaceSet[Qualifier] diff --git a/basyx/aas/model/submodel.py b/basyx/aas/model/submodel.py index 160b63840..00608a29d 100644 --- a/basyx/aas/model/submodel.py +++ b/basyx/aas/model/submodel.py @@ -1111,8 +1111,7 @@ def __init__(self, [] if specific_asset_id is None else specific_asset_id, item_del_hook=self._check_constraint_del_spec_asset_id) self.global_asset_id: Optional[base.Identifier] = global_asset_id - self._entity_type: base.EntityType = entity_type - self._validate_asset_ids_for_entity_type(self.entity_type, self.global_asset_id, self.specific_asset_id) + self.entity_type: base.EntityType = entity_type def _check_constraint_del_spec_asset_id(self, _item_to_del: base.SpecificAssetId, _list: List[base.SpecificAssetId]) -> None: @@ -1120,17 +1119,21 @@ def _check_constraint_del_spec_asset_id(self, _item_to_del: base.SpecificAssetId raise base.AASConstraintViolation( 131, "An AssetInformation has to have a globalAssetId or a specificAssetId") - def _get_entity_type(self) -> base.EntityType: + @property + def entity_type(self) -> base.EntityType: return self._entity_type - def _set_entity_type(self, entity_type: base.EntityType) -> None: + @entity_type.setter + def entity_type(self, entity_type: base.EntityType) -> None: self._validate_asset_ids_for_entity_type(entity_type, self.global_asset_id, self.specific_asset_id) self._entity_type = entity_type - def _get_global_asset_id(self): + @property + def global_asset_id(self): return self._global_asset_id - def _set_global_asset_id(self, global_asset_id: Optional[base.Identifier]): + @global_asset_id.setter + def global_asset_id(self, global_asset_id: Optional[base.Identifier]): self._validate_asset_ids_for_entity_type(self.entity_type, global_asset_id, self.specific_asset_id) self._global_asset_id = global_asset_id @@ -1147,9 +1150,6 @@ def _validate_asset_ids_for_entity_type(entity_type: base.EntityType, if global_asset_id: _string_constraints.check_identifier(global_asset_id) - global_asset_id = property(_get_global_asset_id, _set_global_asset_id) - entity_type = property(_get_entity_type, _set_entity_type) - class EventElement(SubmodelElement, metaclass=abc.ABCMeta): """