As expected, these updates ended up requiring quite a few changes. I was
initially going to update only Marshmallow, but the older version of
webargs couldn't work with an updated Marshmallow, so I ended up needing
to do both at the same time.
The main changes required were:
* Schemas don't need to be specified as "strict" any more, so that could
be removed from constructors and Meta classes.
* .validate() now returns a dict of errors (if any) instead of raising a
ValidationError if anything goes wrong. This meant that I either need
to check the returned dict, or switch to .load() to still get raised
errors.
* Marshmallow doesn't support loading from two different field names as
easily (and changed the name of that to data_key), so all the routes
using "group_path" needed to be changed to just "path".
* Some of the Field methods and some decorated schema ones like
@pre_load receive new arguments and needed to be updated to handle
them and/or pass them on.
* webargs will no longer send a keyword argument for any fields that
aren't specified and don't have a default value when using
@use_kwargs. Because of this, I added missing= values for most
optional fields, but still required some special treatment for the
order query variable in a couple of topic listing views.
And finally, there is some strange behavior in webargs by default when a
form doesn't send any data for a field (due to the input not being
included or similar). When it doesn't find the field in form data, it
tries to fall back to checking for JSON data, but then crashes because
the request doesn't have any JSON data attached. I had to specify only
to look in the form data in a few places to fix this, but I've also
registered an issue against webargs related to it:
https://github.com/marshmallow-code/webargs/issues/444
Updates the Black code-formatter to its newest version and applies it.
They made some small changes to how it handles numeric literals that
affected a few files - both always forcing a "0." prefix on float values
instead of allowing an implicit "0" to be there, as well as only adding
underscore separators if the number has at least 6 digits.
This follows the REUSE practices to add license and copyright info to
all source files: https://reuse.software/practices/2.0/
In addition, LICENSE.md was switched to a plaintext LICENSE file, to
support the tag-value header as recommended.
Note that files that are closer to configuration than code did not have
headers added. This includes all Salt files, Alembic files, and Python
files such as most __init__.py files that only import other files, since
those are similar to header files which are not considered
copyrightable.
Black won't re-wrap comments because it has no way to determine when
that's a "safe" thing to do (that might break deliberate line-breaks).
So this is a quick pass through to re-wrap most multi-line comments and
docstrings to the new max line-length of 88.
This commit contains only changes that were made automatically by Black
(except for some minor fixes to string un-wrapping and two
format-disabling blocks in the user and group schemas). Some manual
cleanup/adjustments will probably need to be made in a follow-up commit,
but this one contains the result of running Black on the codebase
without significant further manual tweaking.