Conversation

Support passing specific fields to partial. This restricts the fields
allowed to be missing during partial deserialization to those specified
in the value of partial.
This is particularly useful in api's when dealing with non client-generated
primary key fields (at creation), where only a specific field is allowed
to be missing, and you'd still like to use the same schema.

This comment has been minimized.

This comment has been minimized.

Frankly, I don't know. It was coercing to bool and I didn't want to change the behavior, this way it still coerces what's left (i.e. not iterable) to bool.
Let me know what you prefer and I'll change it.

This comment has been minimized.

That's the only place where partial is referenced in Unmarshaller and it's a simple if partial check. Changing the default of partial to () -- an empty tuple -- allows doing if field_name in partial there instead.

I misunderstood partial is None before, it's a check in the schema to decide which partial value to use. Instead, if we're using a tuple to declare specific fields to partial, why not do partial = partial or self.partial.

This comment has been minimized.

With partial = partial or self.partial if you pass False, tuple() or anything else that gets implicitly evaluated false, you'll end up using self.partial. So you need to explicitly check for the default value (None).

For example:

s = Schema(partial=True)
s.load({}, partial=False) # partial == True

We can drop the branch if it's OK to not coerce things into bool anymore though.

Support passing specific fields to `partial`. This restricts the fields
allowed to be missing during partial deserialization to those specified
in the value of `partial`.
This is particularly useful in api's when dealing with non client-generated
primary key fields (at creation), where only a specific field is allowed
to be missing, and you'd still like to use the same schema.

This comment has been minimized.

This comment has been minimized.

@sloria@tdevelioglu I was just going over the changelog to upgrade and noticed this PR. Doesn't passing in MySchema(partial=True, exclude=[...]) achieve the same effect as the merged PR's change of passing in MySchema(partial=(...))

Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.