Skip to content

RFC: Import and rename decorators from Marshmallow #62

@greyli

Description

@greyli

I have some doubt about these changes, so I keep it as a undocumentated features so far. Basically, I change the name of the following decorators from Marshamallow:

  • validates -> validate
  • validates_schema -> validate_schema
  • pre_load -> before_load
  • post_load -> after_load
  • pre_dump -> before_dump
  • post_dump -> after_dump

Some ideas behind these changes:

  • validate and validate_schema are short and clear than validates and validates_schema. It also matches the validate keyword in field classes.
  • The change from pre_ to before_ and from post_ to after_ was trying to follow the name convention in Flask (before_request, etc.).

IMO, the new names are easier to understand and intuitive. However, this will definitely introduce "breaking" changes between APIFlask and Marshmallow. I can add a warning in the docs to inform users that they can continue to import everything from marshmallow, but notice the name changes if they want to import from APIFlask.

Is it a good or bad idea? Feel free to leave any thoughts.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions