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

Unwrap decorated objects for YD01 validation check #541

Merged
merged 2 commits into from
Apr 24, 2024

Conversation

rossbar
Copy link
Contributor

@rossbar rossbar commented Apr 15, 2024

The YD01 validation checks that Python generators have a Yields section in the docstring. Currently, this check breaks down for generators that have been decorated, as outer wrapper is a function rather than a generator.

This can at least be improved by traversing an objects __wrapped__ attribute until the original, unwrapped object is found, and then running the is_generator_function check on that.

Note that this unwrapping may be useful in other cases of docstring introspection as well, but I'm limiting it to a known, testable issue here. The added test fails on main for the bar and baz cases. Other improvements related to decorator unwrapping may follow in other PRs!

Additional context

networkx/networkx#7258

@jarrodmillman jarrodmillman merged commit 10f8ae6 into numpy:main Apr 24, 2024
25 checks passed
@stefanv stefanv added this to the 1.8.0 milestone Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants