diff --git a/src/shacl2code/lang/templates/python.j2 b/src/shacl2code/lang/templates/python.j2 index 92d54e33..01e1d713 100644 --- a/src/shacl2code/lang/templates/python.j2 +++ b/src/shacl2code/lang/templates/python.j2 @@ -1188,6 +1188,19 @@ class SHACLObjectSet(object): self.add_index(obj) return obj + def remove(self, obj: SHACLObject) -> None: + """ + Remove object from object set + + Remove a SHACLObject from the object set and rebuild index. + """ + if not isinstance(obj, SHACLObject): + raise TypeError("Object is not of type SHACLObject") + + if obj in self.objects: + self.objects.remove(obj) + self.create_index() + def update(self, *others) -> None: """ Update object set adding all objects in each other iterable