B028: flag empty skip_file_prefixes tuples - #575
Merged
Conversation
An explicitly empty tuple does not raise warnings.warn's effective stacklevel, so B028 should still report it. Keep skipping dynamic and non-empty values, and cover both paths in the eval fixture.
cooperlees
approved these changes
Sep 7, 2026
Collaborator
|
This is an improvement. Thanks! |
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 #510
Summary
warnings.warnreceives an explicitly emptyskip_file_prefixes=()tupleAn empty tuple does not cause
warnings.warnto raise the effective stack level, so treating it like a populatedskip_file_prefixesvalue suppresses a useful B028 diagnostic.Tests
.venv/bin/python -m pytest tests/test_bugbear.py -q(81 passed).venv/bin/tox -e py314(81 passed, 98% coverage).venv/bin/pre-commit run --all-files(isort, black, flake8, rstcheck passed)Limitations
Dynamic expressions remain intentionally conservative: if the value of
skip_file_prefixesis not a literal empty tuple, B028 is skipped as before.