11from typing import List , Union
22
3- from pydantic .main import BaseModel
4- from labelbox .data .annotation_types .classification .classification import Dropdown
5- from labelbox .data .annotation_types .annotation import AnnotationType , ClassificationAnnotation
6-
3+ from labelbox .data .annotation_types .annotation import (AnnotationType ,
4+ ClassificationAnnotation )
5+ from labelbox .data .annotation_types .classification import (CheckList ,
6+ ClassificationAnswer ,
7+ Radio , Text )
8+ from labelbox .data .annotation_types .classification .classification import \
9+ Dropdown
710from labelbox .data .serialization .labelbox_v1 .feature import LBV1Feature
8- from labelbox . data . annotation_types . classification import Text , Radio , CheckList , ClassificationAnswer
11+ from pydantic . main import BaseModel
912
1013
1114class LBV1ClassificationAnswer (LBV1Feature ):
1215 ...
1316
17+
1418class LBV1Radio (LBV1Feature ):
1519 answer : LBV1ClassificationAnswer
1620
@@ -25,14 +29,13 @@ def to_common(self):
2529
2630 @classmethod
2731 def from_common (cls , radio : Radio , schema_id : str , ** extra ) -> "LBV1Radio" :
28- return cls (
29- schema_id = schema_id ,
30- answer = LBV1ClassificationAnswer (
31- schema_id = radio .answer .schema_id ,
32- title = radio .answer .display_name ,
33- value = radio .answer .extra ['value' ],
34- feature_id = radio .answer .extra ['feature_id' ]),
35- ** extra )
32+ return cls (schema_id = schema_id ,
33+ answer = LBV1ClassificationAnswer (
34+ schema_id = radio .answer .schema_id ,
35+ title = radio .answer .display_name ,
36+ value = radio .answer .extra ['value' ],
37+ feature_id = radio .answer .extra ['feature_id' ]),
38+ ** extra )
3639
3740
3841class LBV1Checklist (LBV1Feature ):
@@ -51,16 +54,16 @@ def to_common(self):
5154 @classmethod
5255 def from_common (cls , checklist : CheckList , schema_id : str ,
5356 ** extra ) -> "LBV1Checklist" :
54- return cls (
55- schema_id = schema_id ,
56- answers = [
57- LBV1ClassificationAnswer ( schema_id = answer .schema_id ,
58- title = answer .display_name ,
59- value = answer .extra ['value' ],
60- feature_id = answer .extra ['feature_id' ])
61- for answer in checklist .answer
62- ],
63- ** extra )
57+ return cls (schema_id = schema_id ,
58+ answers = [
59+ LBV1ClassificationAnswer (
60+ schema_id = answer .schema_id ,
61+ title = answer .display_name ,
62+ value = answer .extra ['value' ],
63+ feature_id = answer .extra ['feature_id' ])
64+ for answer in checklist .answer
65+ ],
66+ ** extra )
6467
6568
6669class LBV1Text (LBV1Feature ):
@@ -90,7 +93,11 @@ def to_common(self):
9093 classifications = [
9194 ClassificationAnnotation (value = classification .to_common (),
9295 classifications = [],
93- display_name = classification .title , extra = {'value' : classification .value , 'feature_id' : classification .feature_id })
96+ display_name = classification .title ,
97+ extra = {
98+ 'value' : classification .value ,
99+ 'feature_id' : classification .feature_id
100+ })
94101 for classification in self .classifications
95102 ]
96103 return classifications
0 commit comments