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

Enforceis_valid(raise_exception=False) as a keyword-only argument.#7952

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 2 commits intoencode:masterfromProstoMaxim:is_valid_keyword
Aug 10, 2022

Conversation

ProstoMaxim
Copy link
Contributor

At the momentis_valid calls are possible without keyword-only arguments, so code
serializer.is_valid(True) is possible and will be quite misleading, especially for new developers. This pull requests makes "raise_exception" name mandatory if serializer is called with argument.

CuriousLearner and gopirav39 reacted with hooray emoji
@stale
Copy link

stalebot commentedApr 28, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stalestalebot added the stale labelApr 28, 2022
@tomchristietomchristie changed the titlePrevent misleading is_valid callsEnforceis_valid(raise_exception=False) as a keyword-only argument.Aug 10, 2022
@stalestalebot removed the stale labelAug 10, 2022
@tomchristie
Copy link
Member

This seems like it could be a pretty reasonable change to me, along with a major version bump.

Granted there's probably some codebases that might be forced into a change, OTOH, itis an argument that makes much more sense as a keyword-only case.

Any other maintainers have an opinion on the trade-off here?

@adamchainz
Copy link
Contributor

I like it! This avoids a problem known as "the boolean trap".

tomchristie and CuriousLearner reacted with thumbs up emoji

@tomchristietomchristie merged commit791d48c intoencode:masterAug 10, 2022
@romanek-adam-b2c2
Copy link

It like it too, but it breaks the existing API and changelog doesn't mention that :(

@tomchristie
Copy link
Member

tomchristie commentedSep 29, 2022
edited
Loading

It's inhttps://www.django-rest-framework.org/community/3.14-announcement/ andhttps://www.django-rest-framework.org/community/release-notes/

But yes, upgrades that break thingsare a pain. Even when we want them.

@romanek-adam-b2c2
Copy link

OK, then it would make sense to include a link to the former in the latter, as originally I only found and read the latter (as I was reviewing tons of changelogs for multiple packages which got updated for my project). Additionally I'd suggest explicitly marking breaking changes with some prefix / tag / whatever ("BREAKING: ...") to make sure no one will miss that. Anyway, keep up the good work!

sigvef pushed a commit to sigvef/django-rest-framework that referenced this pull requestDec 3, 2022
…encode#7952)* make raise_exception a keyword-only argument* make raise_exception keyword-only in metaclass
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
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
@ProstoMaxim@tomchristie@adamchainz@romanek-adam-b2c2

[8]ページ先頭

©2009-2025 Movatter.jp