Skip to content

Commit caf3ea5

Browse files
committed
Fix enum validation error msgs
1 parent a70960f commit caf3ea5

File tree

5 files changed

+137
-119
lines changed

5 files changed

+137
-119
lines changed

src/superannotate/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import sys
33

4-
__version__ = "4.4.4dev1"
4+
__version__ = "4.4.4dev2"
55

66
sys.path.append(os.path.split(os.path.realpath(__file__))[0])
77

src/superannotate/lib/app/interface/types.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import Union
66

77
from lib.core.enums import AnnotationStatus
8+
from lib.core.enums import BaseTitledEnum
89
from lib.core.enums import ClassTypeEnum
910
from lib.core.enums import ProjectStatus
1011
from lib.core.enums import ProjectType
@@ -32,7 +33,11 @@ class EnumMemberError(PydanticTypeError):
3233
code = "enum"
3334

3435
def __str__(self) -> str:
35-
permitted = ", ".join(str(v.name) for v in self.enum_values) # type: ignore
36+
enum_values = list(self.enum_values) # noqa
37+
if isinstance(enum_values[0], BaseTitledEnum):
38+
permitted = ", ".join(str(v.name) for v in enum_values) # type: ignore
39+
else:
40+
permitted = ", ".join(str(v.value) for v in enum_values) # type: ignore
3641
return f"Available values are: {permitted}"
3742

3843

src/superannotate/lib/app/serializers.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,13 @@ def serialize(
121121
exclude: Set[str] = None,
122122
):
123123

124-
to_exclude = {"sync_status": True, "unverified_users": True,
125-
"classes": {"__all__": {"attribute_groups": {"__all__": {"is_multiselect"}}}}}
124+
to_exclude = {
125+
"sync_status": True,
126+
"unverified_users": True,
127+
"classes": {
128+
"__all__": {"attribute_groups": {"__all__": {"is_multiselect"}}}
129+
},
130+
}
126131
if exclude:
127132
for field in exclude:
128133
to_exclude[field] = True

src/superannotate/lib/core/entities/classes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def __hash__(self):
9696
return hash(f"{self.id}{self.type}{self.name}")
9797

9898
class Config:
99-
extra = Extra.ignore
99+
extra = Extra.allow
100100
json_encoders = {
101101
HexColor: lambda v: v.__root__,
102102
BaseTitledEnum: lambda v: v.value,

0 commit comments

Comments
 (0)