You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
desert throws an error when a dataclass has more than one subtype other than None
importdesertfromdataclassesimportdataclassfromtypingimportUnionfrommarshmallowimportSchema@dataclassclassMyOptionalKlass:
a: Union[float, str, None] =3schema=desert.schema(MyOptionalKlass)
#> ValueError: too many values to unpack (expected 1)
I think this is to do with the check of is_optional_type() before is_union_type(). I think within the is_optional_type() branch we should create subfields for all remaining subtypes other than NoneType.
Even without the None in the type, the default value of the field is still <marshmallow.missing> rather than 3
The text was updated successfully, but these errors were encountered:
I think this is basically a lead in to #36. Perhaps a simpler 'handle the basic types only' solution could be useful. Or perhaps it is better as a trivial recipe for the general solution. For example, would a JSON true become 1 or 'True' (or 'true') or be rejected?
desert
throws an error when adataclass
has more than one subtype other thanNone
I think this is to do with the check of
is_optional_type()
beforeis_union_type()
. I think within theis_optional_type()
branch we should createsubfields
for all remaining subtypes other thanNoneType
.Even without the
None
in the type, the default value of the field is still<marshmallow.missing>
rather than3
The text was updated successfully, but these errors were encountered: