-
Notifications
You must be signed in to change notification settings - Fork 40
Description
Referable.update_from() patches the self object with the other object by iterating over the attributes of the other objects using the python built-in vars(). vars() only iterates over an objects attributes, not properties e.g. getter/setter functions. The id_short attribute of Referable is a property, which performs additional checks when setting the id_short, such as checking for uniqueness within the namespace by searching the objects contained in the parent object. The actual value of the id_short is stored in the protected attribute _id_short.
Since _id_short is an attribute and id_short is a property, the vars() built-in returns the _id_short attribute instead of the id_short property, which causes update_from() to update the _id_short directly, skipping the setter function and thus the uniqueness check.
This is also the case for the semantic_id property of HasSemantics, which also checks for uniqueness.
A solution proposed by @s-heppner and Michael Thies is to add dictionaries to each class, mapping the protected attributes to the respective property. These dictionaries would then be searched by update_from(), which can then set the property instead of the attribute.
Transferred from: https://git.rwth-aachen.de/acplt/pyi40aas/-/issues/133