-
Notifications
You must be signed in to change notification settings - Fork 1
Conversation
candidate = SchemaPolyfieldProxy(dclass) | ||
candidate.check_deserialization(obj_dict) | ||
return candidate | ||
except Exception: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be more precise? like (TypeError, ValidationError)
(if indeed .dump and .load raise ValidationErrors)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we try every schema, and each of them can trigger an error (we pick the first one that "works")
For example, when we give a string to int schema we get ValueError: invalid literal for int() with base 10: 'hello'
or if we give an int to a dict schema AttributeError: 'int' object has no attribute 'keys'
I suppose custom schema can trigger any type of error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah I see, ok makes sense
marshmallow_dataclass/polyfield.py
Outdated
raise marshmallow.exceptions.ValidationError( | ||
"cannot deserialize") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far, the validation errors are quite specific in the rest of package. Should we make this text a join of the different errors that were raised above? Otherwise they are swallowed.
But maybe it would make this error hard to read, not sure..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
1501a98
to
34e95b7
Compare
marshmallow-union is not supported anymore and have some known issues see: lovasoa#67 Author advise to switch to marshmallow-polyfield
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Let's propose that upstream!
marshmallow-union is not supported anymore and have some known issues
see:
lovasoa#67
Author advise to switch to marshmallow-polyfield