Marshmallow: TypeError: validate_additionally() got an unexpected keyword argument 'many'

Created on 25 Dec 2019  路  1Comment  路  Source: marshmallow-code/marshmallow

I have schema like

from marshmallow import Schema

class CallsSortingSchema(Schema):
    metric = mm.Str(required=True, validate=Length(1, MAX_METRIC_NAME_LENGTH))
    order = mm.Str(required=True, validate=OneOf(['asc', 'desc']))

    @post_load
    def validate_additionally(self, data):
        if not data['metric'].startswith(CUSTOM_METRIC_PREFIX) \
                and data['metric'] not in SORTABLE_METRICS:
            raise ValidationError('metric must be in SORTABLE_METRICS or starts with '
                                  + CUSTOM_METRIC_PREFIX)
        return data

after upgrade from marshmallow==3.0.0b13 tomarshmallow==3.3.0
i got

attr_name = 'validate_additionally', processor_kwargs = {'pass_original': False}

    def _invoke_processors(
        self,
        tag: str,
        *,
        pass_many: bool,
        data,
        many: bool,
        original_data=None,
        **kwargs
    ):
        key = (tag, pass_many)
        for attr_name in self._hooks[key]:
            # This will be a bound method.
            processor = getattr(self, attr_name)

            processor_kwargs = processor.__marshmallow_hook__[key]
            pass_original = processor_kwargs.get("pass_original", False)

            if many and not pass_many:
                if pass_original:
                    data = [
                        processor(item, original, many=many, **kwargs)
                        for item, original in zip(data, original_data)
                    ]
                else:
                    data = [processor(item, many=many, **kwargs) for item in data]
            else:
                if pass_original:
                    data = processor(data, original_data, many=many, **kwargs)
                else:
>                   data = processor(data, many=many, **kwargs)
E                   TypeError: validate_additionally() got an unexpected keyword argument 'many'
question

Most helpful comment

This is explained in the CHANGELOG and the upgrading guide in the docs.

Decorated methods must accept kwargs.

     def validate_additionally(self, data, **kwargs):

>All comments

This is explained in the CHANGELOG and the upgrading guide in the docs.

Decorated methods must accept kwargs.

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

Related issues

DenisKuplyakov picture DenisKuplyakov  路  4Comments

imhoffd picture imhoffd  路  3Comments

ambye85 picture ambye85  路  4Comments

m-novikov picture m-novikov  路  3Comments

nickretallack picture nickretallack  路  4Comments