Fix B901 false positive on pytest hook wrappers#23423
Closed
IMaloney wants to merge 2 commits intoastral-sh:mainfrom
Closed
Fix B901 false positive on pytest hook wrappers#23423IMaloney wants to merge 2 commits intoastral-sh:mainfrom
IMaloney wants to merge 2 commits intoastral-sh:mainfrom
Conversation
B901 flags return statements in generators, but pytest hook wrappers decorated with @hookimpl(wrapper=True) are allowed to return values per pytest docs. Skip B901 when the generator has @hookimpl(wrapper=True) decorator from pytest or pluggy. Fixes astral-sh#21881
Contributor
|
Hi! It looks like there's already an open PR for this issue as well. It might be best to comment on issues you plan to tackle, or to check if the previous PR author is still working on something, in order to avoid duplicate work. |
Author
|
Sorry for the noise |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes B901 false positive on pytest hook wrappers (#21881)
B901 flags return statements in generators, but pytest hook wrappers with @hookimpl(wrapper=True) are allowed to return values per pytest docs
added check to skip B901 when the generator has @hookimpl(wrapper=True) from pytest or pluggy. tested with wrapper=True from both libraries, wrapper=False and bare @hookimpl still get flagged