... the naming of load_only feels like a misnomer ...
I see what you mean with
load_only. I assumed the wrong behavior until I looked at the docs.
load_only: A list or tuple of fields to skip during serialization dump_only: A list or tuple of fields to skip during deserialization, read-only fields
A good way to illustrate why this is a strange interface is to create a schema with a field that is both
class TestSchema(Schema): field1 = fields.Field() field2 = fields.Field() class Meta: load_only=('field1',) dump_only=('field1',)
field1 will not be serialized nor deserialized in this example.
load_only actually means "don't dump" and
dump_only means "don't load".
| | load | dump | | --- | --- | --- | | True | | | | False | dump_only | load_only |
A clearer terminology might be "force" and "skip" which have clear connotations and no implicit behaviors.
| | load | dump | | --- | --- | --- | | True | force_load | force_dump | | False | skip_load | skip_dump |
The only ambiguity is priority, but I believe that in the rest of the library exclusion has priority over inclusion and instances have priority over classes.