Skip to content

Commit c40ebb7

Browse files
committed
shortening of lines and cleaning up code
1 parent d8d16d4 commit c40ebb7

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

labelbox/schema/ontology_generator.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ def asdict(self) -> Dict[str, Any]:
2626
"featureSchemaId": self.feature_schema_id,
2727
"label": self.label,
2828
"value": self.value,
29-
"options": [c.asdict() for c in self.options]
30-
}
29+
"options": [c.asdict() for c in self.options]}
3130

3231
@classmethod
3332
def from_dict(cls, dictionary: Dict[str,Any]):
@@ -36,8 +35,7 @@ def from_dict(cls, dictionary: Dict[str,Any]):
3635
schema_id = dictionary["schemaNodeId"],
3736
feature_schema_id = dictionary["featureSchemaId"],
3837
options = [Classification.from_dict(o)
39-
for o in dictionary.get("options", [])]
40-
)
38+
for o in dictionary.get("options", [])])
4139

4240
def add_option(self, option: 'Classification') -> 'Classification':
4341
if option.instructions in (c.instructions for c in self.options):
@@ -80,8 +78,7 @@ def asdict(self) -> Dict[str,Any]:
8078
"required": self.required,
8179
"options": [o.asdict() for o in self.options],
8280
"schemaNodeId": self.schema_id,
83-
"featureSchemaId": self.feature_schema_id
84-
}
81+
"featureSchemaId": self.feature_schema_id}
8582

8683
@classmethod
8784
def from_dict(cls, dictionary: Dict[str,Any]):
@@ -91,8 +88,7 @@ def from_dict(cls, dictionary: Dict[str,Any]):
9188
required = dictionary["required"],
9289
options = [Option.from_dict(o) for o in dictionary["options"]],
9390
schema_id = dictionary["schemaNodeId"],
94-
feature_schema_id = dictionary["schemaNodeId"]
95-
)
91+
feature_schema_id = dictionary["schemaNodeId"])
9692

9793
def add_option(self, option: Option):
9894
if option.value in (o.value for o in self.options):
@@ -128,8 +124,7 @@ def asdict(self) -> Dict[str,Any]:
128124
"color": self.color,
129125
"classifications": [c.asdict() for c in self.classifications],
130126
"schemaNodeId": self.schema_id,
131-
"featureSchemaId": self.feature_schema_id
132-
}
127+
"featureSchemaId": self.feature_schema_id}
133128

134129
@classmethod
135130
def from_dict(cls, dictionary: Dict[str,Any]):
@@ -141,8 +136,7 @@ def from_dict(cls, dictionary: Dict[str,Any]):
141136
tool = Tool.Type(dictionary["tool"]),
142137
classifications = [Classification.from_dict(c)
143138
for c in dictionary["classifications"]],
144-
color = dictionary["color"]
145-
)
139+
color = dictionary["color"])
146140

147141
def add_classification(self, classification: Classification):
148142
if classification.instructions in (c.instructions
@@ -187,5 +181,4 @@ def add_classification(self, classification: Classification) -> Classification:
187181
def asdict(self):
188182
return {
189183
"tools": [t.asdict() for t in self.tools],
190-
"classifications": [c.asdict() for c in self.classifications]
191-
}
184+
"classifications": [c.asdict() for c in self.classifications]}

0 commit comments

Comments
 (0)