-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Consider using kwargs instead of args in route invocation #429
Comments
What is the benefits of using Just thinking of benefits:
@app.route('{user}/{game_id}')
def get_game(game_id, user):
pass
The main downside though of course is that your handler parameters are now tied to the names of the parameters provided in the route decorator. So it is a bit more work if you change the name of one of the route decorator path variables as you will have to change it in the handler as well. Currently, I do not really have any strong feelings about it. |
Yeah so the feedback was exactly your code snippet. In this case, the expectation for the user was that the We could also give slightly better validation errors if we wanted to validate that for every capture group, you have a corresponding function argument with the same name (with the appropriate edge cases handled for Oh and other benefit is that this is how Flask does it (uses kwargs), so someone who' familiar with Flask might be surprised that we do it slightly different. |
Right. Better validation is something you would also get. I think the |
Yeah FWIW I arbitrarily chose |
Alright. I think I would vote to make it |
We use
*args
when we invoke a view function, whereas**kwargs
seems to make more sense (this is what Flask does).This is technically a breaking change, but will only affect users that don't match their function argument names with the capture group names:
Not sure if it's worth the breaking change, but we should decide if we want to do this now if we want to change it.
Let me know if anyone feels strongly either way.
The text was updated successfully, but these errors were encountered: