I'm wondering if the unknown value set on parent schema should propagate down through all nested schemas.
We raise by default, and to change that, one needs to let all his schemas specify another behaviour (~this is broken but will be fixed when #963 is merged~). This can be done with a custom schema to use as a base for all schemas, so it is feasible, and raise is a sensible default IMHO, but wouldn't it make sense to let the parent schema unknown setting propagate?
I think it's good idea to add fields.Nested.unknown="inherit", which can be set explicitly, but in most cases what I see you don't want to propagate by default, for example you have http json response, which can have various fields, but if field is nested it will be binded to specific entity, and you want to be sure that fields are strict there, so it's each entity (schema) responsibility to react to unknown fields, not related to parent.
Also (off-topic) I think it will be great to have unknown='warn' or unknown='debug' on schema, i will be glad to create pull request if you think this may be useful.
It would be nice to have the option to have all nested schemas inherit.
For now, our stance is that class Meta options should not be automagically propagated to nested fields. Users should use an base schema class in order to share default options across classes.
For now, our stance is that class Meta options should not be automatically propagated to nested fields. Users should use an base schema class in order to share default options across classes.
I do agree that class Meta options should not be automatically propagated.
However, what about when overriding unknown in the load method which should according to documentation override the value set at instantiation or in Meta. For this use case it would make sense to (conditionally) allow propagation to nested fields or ?
At the very least, this behavior should be documented.
I really agree with the previous pro-comments.
I'm using it on load() and it fails for Nested fields, although the doc say:
The unknown option value set in load will override the value applied at instantiation time, which itself will override the value defined in the class Meta.
Which is very much what I'd have expected for nested fields, what the documentation confirms, which however doesn't happen.
Either way: How to solve that? I'm having List() and Item().
I'm sending an instance of a list having items to the server and the server loads and validates sent data via List_Schema().load(unknown=EXCLUDE).
Now an exception is thrown: TypeError: 'X' is an invalid keyword argument for Item
Most helpful comment
I do agree that class Meta options should not be automatically propagated.
However, what about when overriding
unknownin the load method which should according to documentation override the value set at instantiation or in Meta. For this use case it would make sense to (conditionally) allow propagation to nested fields or ?