We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d24b856 commit 4afff3bCopy full SHA for 4afff3b
1 file changed
reflex/state.py
@@ -16,6 +16,7 @@
16
import typing
17
import warnings
18
from collections.abc import AsyncIterator, Callable, Sequence
19
+from enum import Enum
20
from hashlib import md5
21
from importlib.util import find_spec
22
from types import FunctionType
@@ -1880,6 +1881,12 @@ async def _process_event(
1880
1881
hinted_args is tuple or hinted_args is tuple
1882
):
1883
payload[arg] = tuple(value)
1884
+ elif isinstance(hinted_args, type) and issubclass(hinted_args, Enum):
1885
+ try:
1886
+ payload[arg] = hinted_args(value)
1887
+ except ValueError:
1888
+ msg = f"Received an invalid enum value ({value}) for {arg} of type {hinted_args}"
1889
+ raise ValueError(msg) from None
1890
elif (
1891
isinstance(value, str)
1892
and (deserializer := _deserializers.get(hinted_args)) is not None
0 commit comments