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

None with many=True sets valid_data to {} instead of [] #907

Closed
tuukkamustonen opened this Issue Aug 8, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@tuukkamustonen
Contributor

tuukkamustonen commented Aug 8, 2018

With 3.0.0.b13 this now passes:

class Sch(Schema):
    foo = fields.Str()

with pytest.raises(ValidationError) as e:
    Sch(many=True).load(None)
assert e.value.messages == {'_schema': ['Invalid input type.']}
assert e.value.valid_data == {}

This sets valid_data to {} rather than [] as usual with many=True. I understand that we're not really interested about valid_data here, but isn't this kinda confusing because we're expecting a list (for many=True) and valid data is suddenly dictionary instead (invalid)?

@sloria

This comment has been minimized.

Member

sloria commented Aug 9, 2018

Good catch. I agree that valid_data should be a list in that case. PRs welcome.

@sloria sloria added the help wanted label Aug 9, 2018

@sloria sloria added this to the 3.0 milestone Aug 9, 2018

tuukkamustonen added a commit to tuukkamustonen/marshmallow that referenced this issue Aug 9, 2018

tuukkamustonen added a commit to tuukkamustonen/marshmallow that referenced this issue Aug 9, 2018

Fix marshmallow-code#907: Return empty list as `ValidationError.valid…
…_data` with many=True

Only when there's no valid data!

tuukkamustonen added a commit to tuukkamustonen/marshmallow that referenced this issue Aug 9, 2018

Fix marshmallow-code#907: Return empty list as `ValidationError.valid…
…_data` with many=True

Only when there's no valid data!

tuukkamustonen added a commit to tuukkamustonen/marshmallow that referenced this issue Aug 9, 2018

Fix marshmallow-code#907: Return empty list as `ValidationError.valid…
…_data` with many=True

Only when there's no valid data!

tuukkamustonen added a commit to tuukkamustonen/marshmallow that referenced this issue Aug 30, 2018

Fix marshmallow-code#907: Return empty list as `ValidationError.valid…
…_data` with many=True

Only when there's no valid data!

@sloria sloria closed this in bf85149 Sep 18, 2018

sloria added a commit that referenced this issue Sep 18, 2018

Merge pull request #954 from marshmallow-code/906-non-iterables-with-…
…many

Fixes for #906 (TypeError with many=True) and #907 (return [] not {} on many=True error) and #930 (disallows strings and dicts on many=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment