Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_deserialize() got an unexpected keyword argument 'partial' #3

Open
passitalong opened this issue Nov 28, 2021 · 0 comments
Open

_deserialize() got an unexpected keyword argument 'partial' #3

passitalong opened this issue Nov 28, 2021 · 0 comments

Comments

@passitalong
Copy link

passitalong commented Nov 28, 2021

I am getting an error of "_deserialize() got an unexpected keyword argument 'partial'" when I attempt to deserialize with Marshmallow.

  File "/Users/seanhoward/.virtualenvs/MegaTronWeb/lib/python3.9/site-packages/marshmallow/fields.py", line 365, in deserialize
    output = self._deserialize(value, attr, data, **kwargs)
TypeError: _deserialize() got an unexpected keyword argument 'partial'

MA2 appears to require **kwargs be added to all custom serialize/deserialize functions.

see: (marshmallow-code/marshmallow#1286)

I changed _serialize and _deserialize to include , **kwargs and it appears to be working.

class ArrowField(fields.Field):
    """
    An isoformatted datetime string.

    Arrow objects are converted to and from isoformatted strings
    by `Schema.dump` and `Schema.load` respectively.
    """

    default_error_messages = {
        'invalid_object': 'Invalid arrow object.',
        'invalid_datetime': 'Unable to parse datetime.',
    }

    def _serialize(self, value, attr, obj, **kwargs):
        if value is None:
            return None

        return value.isoformat()

    def _deserialize(self, value, attr, data, **kwargs):
        if not value:
            raise self.fail('invalid_object')

        try:
            return arrow.get(value)
        except arrow.parser.ParserError:
            raise self.fail('invalid_datetime')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant