flake8-bugbear icon indicating copy to clipboard operation
flake8-bugbear copied to clipboard

Check for empty `skip_file_prefixes` in `B028`

Open dylwil3 opened this issue 6 months ago • 1 comments

As of https://github.com/PyCQA/flake8-bugbear/pull/503 (cf https://github.com/PyCQA/flake8-bugbear/issues/497) the following emits no lint:

❯ cat example.py
import warnings

warnings.warn("test", skip_file_prefixes=())

❯ uvx --with git+https://github.com/PyCQA/flake8-bugbear flake8 --select B028 check example.py

❯ echo $?
0

But it probably should: the stacklevel is only set to at least 2 if there is at least one prefix given. Of course, the user may pass in a reference to some unknown tuple, in which case it's probably better to skip the lint - but if they explicitly pass an empty tuple, then it makes sense to still emit the lint.

On the other hand I understand if this is overly pedantic and unlikely, so feel free to close the issue as unplanned!

dylwil3 avatar May 12 '25 20:05 dylwil3

I'd accept a PR but this feels unlikely to matter in practice.

JelleZijlstra avatar May 12 '25 21:05 JelleZijlstra