PyCQA / flake8-bugbear

A plugin for Flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle.
MIT License
1.05k stars 103 forks source link

Suppress B901 if function explicitly returns Generator #480

Closed JelleZijlstra closed 6 days ago

JelleZijlstra commented 6 days ago

I got a B901 warning (well, from ruff, not directly from flake8-bugbear) about a function where I use a return statement in a generator. But it was on purpose; returning from a generator is occasionally useful.

I propose to not trigger B901 if the function has an explicit Generator[X, Y, Z] type annotation, because that indicates the author explicitly thought about it.