You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add setter-functions for object attributes that consist of NamespaceSets #65
Now, if a user were to only look at the initialization parameters, and wanted to add a ConceptDictionary later, after initalization, they could theoretically assume, they could set it like this:
This would have terrible results when iterating over ObjectStores containing these objects, since suddenly, we'd get the (not very helpful) error:
AttributeError: 'list' object has no attribute 'update_nss_from'
This obviously points nowhere in the right direction.
I have the suspicion, that this is not the only time, where such a problem may arise. How can we restrrict the user from making such a mistake in the first place? Should we write getter and setter functions for these kinds of attributes? On the other hand, maybe this is something to be checked by the ObjectStore, when adding an item to it?
A typechecker will catch the error of assigning a list where a NamespaceSet is expected. So if the user uses a typechecker (which they should), this won't be an issue. If the user on the other hand assigns a different NamespaceSet to the attribute, I think they should know how to use a NamespaceSet correctly, which is described by the docstring.
We could provide a setter function for the attributes where a NamespaceSet is expected just for usability reasons (I've done that for the OrderedNamespaceSet of SubmodelElementList for example).
You're right, a type-checker would have caught that.
Nevertheless, I'm all for your suggestion of writing setter-functions on attributes where a NamespaceSet is expected. I'll adapt the issue accordingly.
changed the title [-]Confusion when adding `ConceptDescription` after instantiation of `AssetAdministrationShell`[/-][+]Add setter-functions for object attributes that consist of `NamespaceSet`s[/+]on Apr 18, 2023
Activity
jkhsjdhjs commentedon Apr 18, 2023
A typechecker will catch the error of assigning a list where a
NamespaceSetis expected. So if the user uses a typechecker (which they should), this won't be an issue. If the user on the other hand assigns a differentNamespaceSetto the attribute, I think they should know how to use aNamespaceSetcorrectly, which is described by the docstring.We could provide a setter function for the attributes where a
NamespaceSetis expected just for usability reasons (I've done that for theOrderedNamespaceSetofSubmodelElementListfor example).s-heppner commentedon Apr 18, 2023
You're right, a type-checker would have caught that.
Nevertheless, I'm all for your suggestion of writing setter-functions on attributes where a
NamespaceSetis expected. I'll adapt the issue accordingly.[-]Confusion when adding `ConceptDescription` after instantiation of `AssetAdministrationShell`[/-][+]Add setter-functions for object attributes that consist of `NamespaceSet`s[/+]