Skip to content

Should parse allow arguments to be passed through to schema.load and/or dict2schema? #480

@sirosen

Description

@sirosen

I'm looking at the features of marshmallow and Parser.parse (and, by extension, use_args too) and thinking about whether or not this will expose more marshmallow features while not adding too much code (or even, my real goal, simplifying things?).

I have two basic ideas I'm toying with:

  1. the validate argument to parse is basically the same as a schema with validates_schema methods
    • but the validate errors have slightly different messages -- they don't show the schema name (is that good for generated schemas? can a validates_schema method do that?)
    • can these be unified, maybe deprecate validate=..., and remove in 7.0 or later?
  2. there's no way to tell parse to pass unknown to schema.load -- it would be nice to be able to say parse(..., unknown=ma.EXCLUDE)
    • should this just be a container for schema.load arguments, like parse(..., load_params=dict(unknown=ma.INCLUDE, partial=True))? It's a less nice interface to use but more flexible
    • you can handle this today by making different schema objects with your desired behaviors
    • maybe this is doable along with (1) for the dict2schema case by setting attributes of Meta?

This is really low priority. You can do everything today in 6 by using full schema definitions. Supporting unknown=... or load_params=... is really just a convenience feature.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions