-
-
Notifications
You must be signed in to change notification settings - Fork 627
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
Add load_only and dump_only options #131
Conversation
@@ -290,6 +294,8 @@ def deserialize(self, data, fields_dict, many=False, validators=None, | |||
exception_class=UnmarshallingError, | |||
strict=strict | |||
) | |||
if field_obj.dump_only: |
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.
This should go before the call to _call_and_store
. If the field dump-only, no need to do the work of deserializing the value and validating it.
Thanks! Just a minor change to make. Once the tests and docs are added, this is good to merge. |
Done. |
if (value is missing) or (skip_missing and | ||
value in field_obj.SKIPPABLE_VALUES): | ||
skip_conds = ( | ||
field_obj.load_only, |
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.
Actually, we can check field_obj.load_only
before running _call_and_store
as well.
Thanks for adding tests and docs. Just one last change and this is good to merge. |
Uhm, no, we can't. This test is going to fail: https://github.com/marshmallow-code/marshmallow/blob/dev/tests/test_schema.py#L362 This is the reason why I initially put them both after _call_and_store. |
OK. I see. Thanks |
Docstrings and unit tests are still missing. Let me know if these changes are ok and I'll add them.