Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ListField should enforce that input is a list#3513

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@pattisdr
Copy link
Contributor

Purpose

A dictionary is allowed as input in a ListField. If a dictionary is received as input, the keys of the object are retained, and the values are ignored. I assume the ListField should enforce that the input is an array, especially because the error message into_internal_value includes "not a list" if something is wrong with the data.

Changes

Enforces that data cannot be a collections.Mapping.

@pattisdr
Copy link
ContributorAuthor

I could include tuples and sets

if not isinstance(data, (list, tuple, Set)):    self.fail('not_a_list', input_type=type(data).__name__)

@xordoquyxordoquy added this to the3.3.0 Release milestoneOct 16, 2015
@xordoquy
Copy link
Contributor

Thanks for the path.
I don't think it should force to list / tuple / set. Any iterable should do.
The key issue here is that a dictionary is an iterable on the keys.
Questions to be answered:

  • do we really want to limit the valid type to a limited set ?
  • can't we just exclude dictionaries from theListField ?

@pattisdr
Copy link
ContributorAuthor

You're right, I think excluding dictionaries from the ListField in addition to what was already in that line would do the trick.

@lovelydinosaur
Copy link
Contributor

Agree - excluding dicts sounds like a good way around to do this.

@xordoquy
Copy link
Contributor

Note: by dict we should read any mapping type.

@lovelydinosaur
Copy link
Contributor

Note: by dict we should read any mapping type.

IDK - any chance that could be a bit fuzzy in cases we've not thought of?
No strong opinion tho'

@xordoquy
Copy link
Contributor

Well, collections.Mapping should be a good base class to test against (as opposed to just dict).

@foresmac
Copy link

Probably want tests that prove this works as intended.

@xordoquy
Copy link
Contributor

Yup, having tests would be great so we merge it.

@pattisdr
Copy link
ContributorAuthor

Tests added.

@lovelydinosaur
Copy link
Contributor

Looks good, thanks!

lovelydinosaur added a commit that referenced this pull requestNov 18, 2015
…orce_listListField does not enforce that input is a list
@lovelydinosaurlovelydinosaur merged commit04158e1 intoencode:masterNov 18, 2015
@lovelydinosaurlovelydinosaur changed the titleListField does not enforce that input is a listListField should enforce that input is a listNov 18, 2015
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

3.3.2 Release

Development

Successfully merging this pull request may close these issues.

4 participants

@pattisdr@xordoquy@lovelydinosaur@foresmac

[8]ページ先頭

©2009-2025 Movatter.jp