Skip to content

Fix B901 false positive on pytest hook wrappers#23423

Closed
IMaloney wants to merge 2 commits intoastral-sh:mainfrom
IMaloney:fix-b901-hookimpl-wrapper
Closed

Fix B901 false positive on pytest hook wrappers#23423
IMaloney wants to merge 2 commits intoastral-sh:mainfrom
IMaloney:fix-b901-hookimpl-wrapper

Conversation

@IMaloney
Copy link

@IMaloney IMaloney commented Feb 19, 2026

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

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
@ntBre
Copy link
Contributor

ntBre commented Feb 19, 2026

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.

@IMaloney
Copy link
Author

Sorry for the noise

@IMaloney IMaloney closed this Feb 19, 2026
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.

2 participants