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

Make Field constructors keyword-only#7632

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

Merged
tomchristie merged 1 commit intoencode:masterfromakx:field-kwargs-only
Aug 6, 2021

Conversation

akx
Copy link
Contributor

@akxakx commentedNov 10, 2020

Description

This PR makes the Field constructor keyword-only by adding a* (and turning*args, **kwargs into just**kwargs in subclasses). I don't believe anyone is (or should be) constructing fields asserializers.CharField(False, True, False, serializers.empty, ...)

The root issue this fixes is the nonobvious problem in e.g.

aliases=serializers.ListField(serializers.CharField(),default=list)

– you wouldn't expect that yields a non-validated read-only list field, would you? 😄 What happens is the positionalserializers.CharField() argument gets passed up into theserializers.Field() call as the first argument, which just so happens to beread_only, and the field instance is a truthy value...

/cc@magdapoppins for having initially bumped into this issue.

auvipy reacted with thumbs up emoji
Copy link
Member

@auvipyauvipy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

could you please fix the conflicts?

@akx
Copy link
ContributorAuthor

akx commentedApr 16, 2021

@auvipy Rebased.

@akx
Copy link
ContributorAuthor

akx commentedJul 22, 2021

@auvipy Can we get this merged? :)

@auvipy
Copy link
Member

I am not maintainer :D

@akx
Copy link
ContributorAuthor

akx commentedAug 6, 2021

Fair.@tomchristie or someone else, can you take a look?

auvipy reacted with thumbs up emoji

@tomchristie
Copy link
Member

Yup seems pretty reasonable.
We'll want to call it out clearly in the release notes, tho.

@tomchristietomchristie merged commitfdb4931 intoencode:masterAug 6, 2021
@tomchristie
Copy link
Member

Based on past experience I'd expect thatsomeonesomewhere may well have some code updating to do after this change, but let's see. And yes it clearly makes sense.

@tomchristie
Copy link
Member

Based on past experience I'd expect that someone somewhere may well have some code updating to do after this change, but let's see.

And there we go:fdb4931#r54532785

Wemight reconsider this given that we've already seen a user hit a pain point with the change, even without having released a new version. Unsure.

@auvipy
Copy link
Member

documenting this would be the right choice, IMHO

@akx
Copy link
ContributorAuthor

akx commentedSep 1, 2021

Cc@afparsons for having bumped into that issue infdb4931#r54532785:

I believe the change in this PR is net positive and will likely uncover some bugs in downstream code even if it might need some work to adapt. In that sense I agree with@auvipy that it'd be better to just document this loudly for the next release.

auvipy reacted with thumbs up emoji

@tomchristietomchristie mentioned this pull requestDec 10, 2021
tomchristie added a commit that referenced this pull requestDec 10, 2021
sigvef pushed a commit to sigvef/django-rest-framework that referenced this pull requestDec 3, 2022
@asottile-sentry
Copy link

I'm extremely late to the party but this now makesMultipleChoiceField andChoiceField have incompatible signatures --ChoiceField haschoices as a positional argument and now it's required to be namedonly inMultipleChoiceField

unclear if this was intended -- but it certainly strikes me as odd

asottile-sentry added a commit to getsentry/sentry that referenced this pull requestJul 21, 2023
asottile-sentry added a commit to getsentry/sentry that referenced this pull requestJul 21, 2023
armenzg pushed a commit to getsentry/sentry that referenced this pull requestJul 24, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@auvipyauvipyauvipy requested changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@akx@auvipy@tomchristie@asottile-sentry

[8]ページ先頭

©2009-2025 Movatter.jp