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'
This is explained in the CHANGELOG and the upgrading guide in the docs.
Decorated methods must accept kwargs.
def validate_additionally(self, data, **kwargs):
Most helpful comment
This is explained in the CHANGELOG and the upgrading guide in the docs.
Decorated methods must accept kwargs.