1313from pydantic .color import Color
1414from pydantic .color import ColorType
1515from pydantic .datetime_parse import parse_datetime
16+ from pydantic .errors import EnumMemberError
17+
18+
19+ def enum_error_handling (self ) -> str :
20+ permitted = ', ' .join (repr (v .value ) for v in self .enum_values )
21+ return f'Invalid value, permitted: { permitted } '
22+
23+
24+ EnumMemberError .__str__ = enum_error_handling
1625
1726
1827NotEmptyStr = constr (strict = True , min_length = 1 )
@@ -53,7 +62,7 @@ class VectorAnnotationTypeEnum(str, Enum):
5362class CreationTypeEnum (str , Enum ):
5463 MANUAL = "Manual"
5564 PREDICTION = "Prediction"
56- PRE_ANNOTATION = "Pre-annotation "
65+ PRE_ANNOTATION = "Preannotation "
5766
5867
5968class AnnotationStatusEnum (str , Enum ):
@@ -103,7 +112,6 @@ class BboxPoints(BaseModel):
103112
104113
105114class TimedBaseModel (BaseModel ):
106- # TODO change to datetime
107115 created_at : StringDate = Field (None , alias = "createdAt" )
108116 updated_at : StringDate = Field (None , alias = "updatedAt" )
109117
@@ -118,9 +126,9 @@ class TrackableModel(BaseModel):
118126 updated_by : Optional [UserAction ] = Field (None , alias = "updatedBy" )
119127 creation_type : Optional [CreationTypeEnum ] = Field (CreationTypeEnum .PRE_ANNOTATION .value , alias = "creationType" )
120128
121- @validator ("creation_type" )
122- def clean_creation_type (cls , value ):
123- return value or CreationTypeEnum .PRE_ANNOTATION .value
129+ @validator ("creation_type" , always = True )
130+ def clean_creation_type (cls , _ ):
131+ return CreationTypeEnum .PRE_ANNOTATION .value
124132
125133
126134class LastUserAction (BaseModel ):
0 commit comments