Marshmallow: TypeError:@validates_schema got an unexpected keyword argument 'partial'

Created on 21 Mar 2020  Â·  1Comment  Â·  Source: marshmallow-code/marshmallow

I go this wierd error:

TypeError: validate_schema() got an unexpected keyword argument 'partial'

using this code with flask_marhsmallow, flask_restx and flask_accepts:

schemas:

class EmailSchema(ma.Schema):
    email = ma.Email()


class UsernameSchema(ma.Schema):
    username = ma.String()


class ConfirmPasswordSchema(ma.Schema):
    password = ma.String()
    confirmation = ma.String()

    @validates_schema
    def validate_schema(self, data):
        if data.password != data.confirmation:
            raise ValidationError("Incorrect password confirmation")


class AccountSchema(ma.SQLAlchemySchema, EmailSchema, UsernameSchema, ConfirmPasswordSchema):

    class Meta:
        model = User

    id = ma.Integer(required=True)
    name = ma.String(required=True)

usage of schema

@api.route('/')
class Account(Resource):

    @accepts(schema=AccountSchema, api=api)
    @responds(schema=AccountSchema, api=api)
    def post(self):
       ...

Is it possible that there is a problem with extending schemas?

question

Most helpful comment

See https://marshmallow.readthedocs.io/en/stable/api_reference.html#module-marshmallow.decorators

Methods decorated with pre_load, post_load, pre_dump, post_dump, and validates_schema receive many as a keyword argument. In addition, pre_load, post_load, and validates_schema receive partial. If you don’t need these arguments, add **kwargs to your method signature.

    @validates_schema
    def validate_schema(self, data, **kwargs):

>All comments

See https://marshmallow.readthedocs.io/en/stable/api_reference.html#module-marshmallow.decorators

Methods decorated with pre_load, post_load, pre_dump, post_dump, and validates_schema receive many as a keyword argument. In addition, pre_load, post_load, and validates_schema receive partial. If you don’t need these arguments, add **kwargs to your method signature.

    @validates_schema
    def validate_schema(self, data, **kwargs):
Was this page helpful?
0 / 5 - 0 ratings

Related issues

k0nsta picture k0nsta  Â·  4Comments

zohuchneg picture zohuchneg  Â·  3Comments

lupodellasleppa picture lupodellasleppa  Â·  3Comments

agatheblues picture agatheblues  Â·  3Comments

j4k0bk picture j4k0bk  Â·  3Comments