• Deimos's avatar
    Un-pin and update Marshmallow and webargs · 110a9308
    Deimos authored
    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
    110a9308
notifications.py 2.17 KB