Skip to content

Commit

Permalink
model.{aas, submodel}: improve `{AssetInformation, Entity}.global_ass…
Browse files Browse the repository at this point in the history
…et_id` type hints
  • Loading branch information
jkhsjdhjs authored and s-heppner committed Nov 14, 2023
1 parent 7fdb952 commit e39f16e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions basyx/aas/model/aas.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ def __init__(self,
self._specific_asset_id: base.ConstrainedList[base.SpecificAssetId] = \
base.ConstrainedList(specific_asset_id, item_set_hook=self._check_constraint_set_spec_asset_id,
item_del_hook=self._check_constraint_del_spec_asset_id)
self.global_asset_id: Optional[base.Identifier] = global_asset_id
self._global_asset_id: Optional[base.Identifier]
# AASd-131 is validated via the global_asset_id setter
self.global_asset_id = global_asset_id
self.asset_type: Optional[base.Identifier] = asset_type
self.default_thumbnail: Optional[base.Resource] = default_thumbnail

Expand All @@ -78,11 +80,11 @@ def _check_constraint_del_spec_asset_id(self, _item_to_del: base.SpecificAssetId
self._validate_asset_ids(self.global_asset_id, len(list_) > 1)

@property
def global_asset_id(self):
def global_asset_id(self) -> Optional[base.Identifier]:
return self._global_asset_id

@global_asset_id.setter
def global_asset_id(self, global_asset_id: Optional[base.Identifier]):
def global_asset_id(self, global_asset_id: Optional[base.Identifier]) -> None:
self._validate_asset_ids(global_asset_id, bool(self.specific_asset_id))
if global_asset_id is not None:
_string_constraints.check_identifier(global_asset_id)
Expand Down
4 changes: 2 additions & 2 deletions basyx/aas/model/submodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,11 +1144,11 @@ def entity_type(self, entity_type: base.EntityType) -> None:
self._entity_type = entity_type

@property
def global_asset_id(self):
def global_asset_id(self) -> Optional[base.Identifier]:
return self._global_asset_id

@global_asset_id.setter
def global_asset_id(self, global_asset_id: Optional[base.Identifier]):
def global_asset_id(self, global_asset_id: Optional[base.Identifier]) -> None:
self._validate_asset_ids_for_entity_type(self.entity_type, global_asset_id, bool(self.specific_asset_id))
if global_asset_id is not None:
_string_constraints.check_identifier(global_asset_id)
Expand Down

0 comments on commit e39f16e

Please sign in to comment.