Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
schema load None #511
I would be open to changing the behavior for deserializing
I think there would be two level validation.
Just my subjective opinion, for yours' discussion.
Wouldn't it be better if
Currently, this is what happens:
I'm not sure whether
I think I like option 2 better. More explicit. And it doesn't break symmetry (
Anybody can provide a use case for
@sloria, I guess this should be labeled backwards_incompat.
I just opened a PR with an implementation of option 2 (raise
By just removing the
@pytest.mark.parametrize('data', [True, False, 42, None, ]) def test_deserialize_raises_exception_if_input_type_is_incorrect(data): class MySchema(Schema): foo = fields.Field() bar = fields.Field() with pytest.raises(ValidationError) as excinfo: MySchema().load(data) assert 'Invalid input type.' in str(excinfo) exc = excinfo.value assert exc.field_names == ['_schema'] assert exc.fields == 
@sloria, do you think we need a specific
On second thought, I was wrong about symmetry and
As is, it makes no sense, what I meant was more like
MyObject(**load(dump(input_obj)) == input_obj
and I don't think there's a way to achieve this in all cases.
An object can be instantiated from the load of the dump of its own data only if the schema loads all necessary data and it the object class knows how to create it with this data.