File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change 1616import typing
1717import warnings
1818from collections .abc import AsyncIterator , Callable , Sequence
19+ from enum import Enum
1920from hashlib import md5
2021from importlib .util import find_spec
2122from types import FunctionType
@@ -1880,6 +1881,12 @@ async def _process_event(
18801881 hinted_args is tuple or hinted_args is tuple
18811882 ):
18821883 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
18831890 elif (
18841891 isinstance (value , str )
18851892 and (deserializer := _deserializers .get (hinted_args )) is not None
You can’t perform that action at this time.
0 commit comments