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

Use functools.wraps with decorators #52599

Merged
merged 3 commits into from
Apr 18, 2019

Conversation

waynew
Copy link
Contributor

@waynew waynew commented Apr 18, 2019

What does this PR do?

Otherwise, we're not fully wrapping the function so expected attributes
(at least opts anyway) go missing.

What issues does this PR fix or reference?

Fixes #44639

Previous Behavior

See #44639, but basically, any function that was _decorated with with_deprecated or is_deprecated will 🔥 💥 when set as a prereq, because we're introspecting the function to get __opts__, but because we're hitting the decorator instead of the original function it goes down like a lead zeppelin.

New Behavior

Now that the _decorated function uses functools.wraps, proper introspection is proper and leads to the original function instead of _decorated 🙌

Tests written?

No(t yet?) - I'm not exactly sure what (if any) the best test would be here :suspect:

Commits signed with GPG?

Yes

Otherwise, we're not fully wrapping the function so expected attributes
(at least __opts__ anyway) go missing.

Fixes saltstack#44639
waynew added 2 commits April 18, 2019 11:06
During testing I also discovered that `_ignores_kwargs` was also missing
the @wraps decorator. Now it has it.
@dwoz dwoz merged commit 86a9bde into saltstack:2018.3 Apr 18, 2019
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 this pull request may close these issues.

3 participants