clarkduvall / serpy

ridiculously fast object serialization
http://serpy.readthedocs.org/en/latest/
MIT License
960 stars 62 forks source link

Inconsistent: child serializer required=False returns None #39

Closed anentropic closed 7 years ago

anentropic commented 7 years ago

Serpy seems to be designed to omit a field from the serialized data if the field has required=False

However if you use a Serializer as a field, i.e. a child serializer, then the field is always present in the data.

Is this inconsistency deliberate?

...or should this part maybe not be indented as part of the else block? https://github.com/clarkduvall/serpy/blob/master/serpy/serializer.py#L110

anentropic commented 7 years ago

no, actually it doesn't behave that way at all, I was hallucinating

anentropic commented 7 years ago

Maybe README could make clearer what required attr is used for.

required=False just bypasses the field's type-coercion, a kind of a short-circuit for null/None value. The name is a bit misleading.