Should `parse` allow arguments to be passed through to `schema.load` and/or `dict2schema`?
See original GitHub issueI’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:
- the
validate
argument toparse
is basically the same as a schema withvalidates_schema
methods- but the
validate
errors have slightly differentmessages
– they don’t show the schema name (is that good for generated schemas? can avalidates_schema
method do that?) - can these be unified, maybe deprecate
validate=...
, and remove in 7.0 or later?
- but the
- there’s no way to tell
parse
to passunknown
toschema.load
– it would be nice to be able to sayparse(..., unknown=ma.EXCLUDE)
- should this just be a container for
schema.load
arguments, likeparse(..., 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
?
- should this just be a container for
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.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
argschema package — argschema 1.1.1 documentation
Module that contains the base class ArgSchemaParser which should be subclassed ... line arguments passed to the module, if None use argparse to...
Read more >Schema - Documentation - Parse Platform
A Parse.Schema object is for handling schema data from Parse. All the schemas methods require MasterKey. const schema = new Parse.Schema(' ...
Read more >LXML issue parsing XML schema in Python 3 - Stack Overflow
As I understand it, LXML doesn't read the file itself; one must open the file ( as f ) and pass that to...
Read more >Parse JSON - How to get the Schema (Easy Method) - YouTube
In this video, I go through the easy method of how to write/get the schema for the Parse JSON action. Power Automate is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m not sure, but it sounds like you might be suggesting simply dropping
validate=...
in a future release, since it’s only one narrow case that’s hurt by this? I’d be okay with that.We could change the docs around to use more explicit schema classes in the examples, and shift to preferring schemas over dicts throughout the documentation.
Let’s maybe just drop (2) from discussion – it’s only really relevant for the “dict schema” usage, and I think it’s fine to just say that that usage is less flexible and “you should use real schemas if you want more features”.
I haven’t used apispec, but I think this is another reason not to bend over backwards to handle “dict schemas” better. Users can always (on marshmallow3) just use
myschema = ma.Schema.from_dict(...)()
themselves, if they’re determined not to use theclass
keyword! 😝We have #507 which tracks the
unknown
behavior – and we’re working on actually implementing that – so I’m going to close this. Especially given that webargs 7 is going to have per-location defaults forunknown
, I don’t think the idea of passing through arbitrary arguments is very compelling.