Skip to content
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

Function _http_view_func_wrapper should use @functools.wraps #178

Closed
svleeuwen opened this issue Mar 24, 2022 · 3 comments · Fixed by #179
Closed

Function _http_view_func_wrapper should use @functools.wraps #178

svleeuwen opened this issue Mar 24, 2022 · 3 comments · Fixed by #179

Comments

@svleeuwen
Copy link
Contributor

For example when using Flask-Talisman you can specify per-view options using:

@functions_framework.http
@talisman(content_security_policy=None)
def foo(request):
    ...

Talisman will decorate the view function with a talisman_view_options attribute which is retrieved later like this:

view_options = getattr(view_function, 'talisman_view_options', {})

Adding functools.wraps makes sure all function attributes are copied from the original function to the _http_view_func_wrapper.

Will create a pull request for this in a minute.

svleeuwen added a commit to svleeuwen/functions-framework-python that referenced this issue Mar 24, 2022
To make sure function attributes are copied to `_http_view_func_wrapper`
@anniefu
Copy link
Contributor

anniefu commented Mar 25, 2022

Hello, thanks for filing this issue!

This seems like a good change to add. Would it be possible for you to add a unit test and open a PR?

svleeuwen added a commit to svleeuwen/functions-framework-python that referenced this issue Apr 1, 2022
@svleeuwen
Copy link
Contributor Author

@anniefu added test to PR

anniefu added a commit that referenced this issue May 10, 2022
* fix: Add functools.wraps decorator (#178)

To make sure function attributes are copied to `_http_view_func_wrapper`

Co-authored-by: Annie Fu <16651409+anniefu@users.noreply.github.com>
@anniefu
Copy link
Contributor

anniefu commented Jun 7, 2022

Fixed with #179

@anniefu anniefu closed this as completed Jun 7, 2022
@anniefu anniefu linked a pull request Jun 7, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants