-
-
Notifications
You must be signed in to change notification settings - Fork 629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix load parameter *unknow* propagation #1429
base: dev
Are you sure you want to change the base?
Fix load parameter *unknow* propagation #1429
Conversation
3a986fc
to
3d94ded
Compare
When deserializing a data structure with the load method, the *unknown* was not propagated to the loading of nested data structures. As result, if a unknown field was present into a nested data structure a ValidationError was raised even if the load methd was called with *unknown=EXCLUDE*. This commit ensures that this parameter is now propagated also to the loading of nested data structures. fixes marshmallow-code#1428
3d94ded
to
e1acdd7
Compare
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, i have just one nit comment
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.
Thanks, LGTM
from marshmallow import fields, Schema, RAISE, INCLUDE, EXCLUDE
class C(Schema):
foo = fields.Str()
class Meta:
unknown = EXCLUDE
class B(Schema):
c = fields.Nested(C)
class A(Schema):
b = fields.Nested(B, unknown=INCLUDE)
class Meta:
unknown = RAISE
schema = A()
print(schema.load({
'b': {
'extra': 'good',
'c': {
'foo': 'bar',
'unexpected': 'bad'
}
}
})) Current behavior (3.2.2): {'b': {'c': {'foo': 'bar'}, 'extra': 'good'}} Proposed behavior: {'b': {'c': {'foo': 'bar', 'unexpected': 'bad'}, 'extra': 'good'}} |
The changelog entry, including credit to prior related work, covers the closed issues and describes how `propagate_unknown` is expected to behave. Inline documentation attempts to strike a balance between clarify and brevity. closes marshmallow-code#1428, marshmallow-code#1429, marshmallow-code#1490, marshmallow-code#1575
The changelog entry, including credit to prior related work, covers the closed issues and describes how `propagate_unknown` is expected to behave. Inline documentation attempts to strike a balance between clarify and brevity. closes marshmallow-code#1428, marshmallow-code#1429, marshmallow-code#1490, marshmallow-code#1575
The changelog entry, including credit to prior related work, covers the closed issues and describes how `propagate_unknown` is expected to behave. Inline documentation attempts to strike a balance between clarify and brevity. closes marshmallow-code#1428, marshmallow-code#1429, marshmallow-code#1490, marshmallow-code#1575
When deserializing a data structure with the load method, the unknown was not propagated to the loading of nested data structures. As result, if a unknown field was present into a nested data structure a ValidationError was raised even if the load methd was called with unknown=EXCLUDE. This commit ensures that this parameter is now propagated also to the loading of nested data structures.
fixes #1428