Skip to content

Commit 9805e93

Browse files
author
gabino
committed
fix: update __get_value return type to support broader value types
1 parent 5be6869 commit 9805e93

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mongoengine_plus/types/enum_field.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from enum import Enum
2-
from typing import Type
2+
from typing import Any, Type, Union
33

44
from mongoengine.base import BaseField
55

@@ -18,8 +18,8 @@ def __init__(self, enum: Type[Enum], *args, **kwargs):
1818
kwargs['choices'] = [choice for choice in enum]
1919
super(EnumField, self).__init__(*args, **kwargs)
2020

21-
def __get_value(self, enum: Enum) -> str:
22-
return enum.value
21+
def __get_value(self, enum: Enum) -> Union[str, Any]:
22+
return enum.value if hasattr(enum, 'value') else enum
2323

2424
def to_python(self, value: Enum) -> Enum: # pragma: no cover
2525
return self.enum(super(EnumField, self).to_python(value))

0 commit comments

Comments
 (0)