marshmallow-oneofschema
marshmallow-oneofschema copied to clipboard
Inconsistency of return type of OneOfSchema.load
Hi there,
The current implementation of OneOfSchema.load
is causing me errors downstream due to heterogeneity of the type of objects being returned.
My particular issue was due to how result
is constructed when there's a ValdidationError
for many==False
(have a look here).
In the current implementation, result
ends up being nested in a list [{"type": "foo"}]
when there is a ValidationError (through the valid_data attribute), and equal to the input when where's no error.
Secondly result
is constructed in a what appears to be an overly convoluted way where result gets set, then appended to a different variable that the overwrites the result....
I would gladly make a PR with a refactored version of OneOfSchema.load
if that's allowed?