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

FIX: Don't default to list in method args#2518

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
lovelydinosaur merged 3 commits intoencode:masterfromlonghotsummer:patch-1
Feb 4, 2015
Merged

FIX: Don't default to list in method args#2518

lovelydinosaur merged 3 commits intoencode:masterfromlonghotsummer:patch-1
Feb 4, 2015

Conversation

@longhotsummer
Copy link
Contributor

Fixes@list_route and@detail_route so that they don't initialize theirmethods parameter as a list. In some cases the list gets cleared, and the result is that default parameter is now empty, and may get reused unexpectedly.

Fixes @list_route and @detail_route so that they don't initialize their `methods` parameter as a list. In some cases the list gets cleared, and the result is that default parameter is now empty, and may get reused unexpectedly.
@xordoquy
Copy link
Contributor

Good catch though I'd probably rather have them as a tuple to avoid mutability.

Copy link
Contributor

Choose a reason for hiding this comment

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

Add a newline here, also let's use themethods = ['get'] if (methods is None) else methods style.

Copy link
Contributor

Choose a reason for hiding this comment

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

Minor one, this, but I tend to prefer using brackets around the if clause for visual clarity, so I normally do...

['get'] if (methods is None) else methods

@lovelydinosaur
Copy link
Contributor

I'll take this either with or without tuples. Happy for that to be discussed separately as it's a slightly different issue.

@lovelydinosaur
Copy link
Contributor

In some cases the list gets cleared

This fix is clearly correct, but I'd be interested to know in what context the list gets mutated?

@longhotsummer
Copy link
ContributorAuthor

Regarding tuples, I chose not to use them because I didn't want to mess with any code which is trying to change the list (even if it shouldn't be), I didn't want to go down that path right now.

I'm using a pretty standard setup and I just happened to notice that if I used:

@detail_routedef foo(self, request, *args, **kwargs):

it just didn't show up. Digging showed me that the methods param was empty.

@lovelydinosaurlovelydinosaur added this to the3.0.5 Release milestoneFeb 4, 2015
@lovelydinosaur
Copy link
Contributor

Okay, so just thebrackets around the if clause for visual clarity and then I'm happy for this to go in.
Thanks! 😄 ✨

lovelydinosaur added a commit that referenced this pull requestFeb 4, 2015
FIX: Don't default to list in method args
@lovelydinosaurlovelydinosaur merged commit3b00824 intoencode:masterFeb 4, 2015
@lovelydinosaur
Copy link
Contributor

Loverly.

@xordoquy
Copy link
Contributor

Thanks for tracking this down, this is a very tricky Python side effect.

@longhotsummer
Copy link
ContributorAuthor

👍 it has caught me a few times

@maryokhin
Copy link
Contributor

it just didn't show up.

It did work for me if used as@detail_route(), but not as@detail_route. I even thought that I didn't understand how decorators work in Python for a while, and that's how it should be.

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

Projects

None yet

Milestone

3.0.5 Release

Development

Successfully merging this pull request may close these issues.

4 participants

@longhotsummer@xordoquy@lovelydinosaur@maryokhin

[8]ページ先頭

©2009-2025 Movatter.jp