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

dump/load gives Invalid input type #65

Closed
neggert opened this issue Feb 15, 2019 · 4 comments
Closed

dump/load gives Invalid input type #65

neggert opened this issue Feb 15, 2019 · 4 comments

Comments

@neggert
Copy link

neggert commented Feb 15, 2019

Using schema().load() does not seem to work for classes that contain lists. I can reproduce this even with the Boss/Minion example from the documentation

@dataclass_json
@dataclass(frozen=True)
class Minion:
    name: str


@dataclass_json
@dataclass(frozen=True)
class Boss:
    minions: List[Minion]

boss = Boss([Minion('evil minion'), Minion('very evil minion')])
boss_dict = Boss.schema().dump(boss)
Boss.schema().load(boss_dict)
marshmallow.exceptions.ValidationError: {'_schema': ['Invalid input type.']}

For what it's worth, going all the way to JSON and back seems to work fine:

boss_json = boss.to_json()
Boss.from_json(boss_json)
@nuklea
Copy link

nuklea commented Feb 15, 2019

Same issue with 0.2.1

@nuklea
Copy link

nuklea commented Feb 15, 2019

from dataclasses import dataclass
from typing import List

from dataclasses_json import DataClassJsonMixin


@dataclass
class Entity(DataClassJsonMixin):
    id: int


@dataclass
class Container(DataClassJsonMixin):
    entities: List[Entity]


@dataclass
class Data(DataClassJsonMixin):
    container: Container


schema = Data.schema()
schema.load({'container': {'entities': [{'id': 1}]}})
marshmallow.exceptions.ValidationError: {'container': {'entities': {'_schema': ['Invalid input type.']}}}

@nuklea
Copy link

nuklea commented Feb 16, 2019

But works fine with 0.1.0

This was referenced Feb 21, 2019
@lidatong
Copy link
Owner

Thanks for reporting this. Fixed in #66

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

3 participants