Custom field serialzer in flattened field bug
Opened this issue · 0 comments
AustinScola commented
It appears that a custom field serializer inside of a flattened field fails to serialzie:
Example:
from serde import field, serialize, to_dict
@serialize
class Child:
value: int = field(serializer=str)
@serialize
class Parent:
child: Child = field(flatten=True)
parent = Parent(child=Child(value=3))
print(to_dict(parent))
Stacktrace:
Traceback (most recent call last):
File "/private/tmp/foo.py", line 12, in <module>
print(to_dict(parent))
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/serde/se.py", line 450, in to_dict
return to_obj( # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/serde/se.py", line 378, in to_obj
raise SerdeError(e) from None
serde.compat.SerdeError: name 'value_serializer' is not defined