11from typing import Any , Dict , List
22
3- from pydantic .main import BaseModel
3+ try :
4+ from typing import Literal
5+ except :
6+ from typing_extensions import Literal
47
8+ from pydantic import BaseModel , validator
59from ..feature import FeatureSchema
610
711
12+ # TODO: Replace when pydantic adds support for unions that don't coerce types
13+ class _TempName (BaseModel ):
14+ name : str
15+
16+ def dict (self , * args , ** kwargs ):
17+ res = super ().dict (* args , ** kwargs )
18+ res .pop ('name' )
19+ return res
20+
21+
822class ClassificationAnswer (FeatureSchema ):
923 """
1024 - Represents a classification option.
@@ -19,8 +33,9 @@ class Radio(BaseModel):
1933 answer : ClassificationAnswer
2034
2135
22- class Checklist (BaseModel ):
36+ class Checklist (_TempName ):
2337 """ A classification with many selected options allowed """
38+ name : Literal ["checklist" ] = "checklist"
2439 answer : List [ClassificationAnswer ]
2540
2641
@@ -29,9 +44,10 @@ class Text(BaseModel):
2944 answer : str
3045
3146
32- class Dropdown (BaseModel ):
47+ class Dropdown (_TempName ):
3348 """
3449 - A classification with many selected options allowed .
3550 - This is not currently compatible with MAL.
3651 """
52+ name : Literal ["dropdown" ] = "dropdown"
3753 answer : List [ClassificationAnswer ]
0 commit comments