@@ -160,15 +160,15 @@ class RelationshipTool(Tool):
160
160
"""
161
161
A relationship tool to be added to a Project's ontology.
162
162
163
- To instantiate, the "tool" and "name" parameters must
164
- be passed in .
163
+ The "tool" parameter is automatically set to Tool.Type.RELATIONSHIP
164
+ and doesn't need to be passed during instantiation .
165
165
166
166
The "classifications" parameter holds a list of Classification objects.
167
167
This can be used to add nested classifications to a tool.
168
168
169
169
Example(s):
170
170
tool = RelationshipTool(
171
- name = "Relationship Tool example")
171
+ name = "Relationship Tool example",
172
172
constraints = [
173
173
("source_tool_feature_schema_id_1", "target_tool_feature_schema_id_1"),
174
174
("source_tool_feature_schema_id_2", "target_tool_feature_schema_id_2")
@@ -180,7 +180,7 @@ class RelationshipTool(Tool):
180
180
tool.add_classification(classification)
181
181
182
182
Attributes:
183
- tool: Tool.Type.RELATIONSHIP
183
+ tool: Tool.Type.RELATIONSHIP (automatically set)
184
184
name: (str)
185
185
required: (bool)
186
186
color: (str)
@@ -191,13 +191,12 @@ class RelationshipTool(Tool):
191
191
constraints: (list of [str, str])
192
192
"""
193
193
194
- tool : Type = Tool .Type .RELATIONSHIP
195
194
constraints : Optional [List [Tuple [str , str ]]] = None
196
195
197
196
def __post_init__ (self ):
197
+ # Ensure tool type is set to RELATIONSHIP
198
+ self .tool = Tool .Type .RELATIONSHIP
198
199
super ().__post_init__ ()
199
- if self .tool != Tool .Type .RELATIONSHIP :
200
- raise ValueError ("RelationshipTool can only be used with Tool.Type.RELATIONSHIP" )
201
200
202
201
def asdict (self ) -> Dict [str , Any ]:
203
202
result = super ().asdict ()
0 commit comments