[flake8-bugbear
] Implement quoted-fstring-value
(B907
)
#11977
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.
Summary
Implements rule B907
quoted-fstring-value
.Tracking Issue: #3758
From the bugbear documentation
Changes from original
The original rule in bugbear was marked as optional/opinionated (PyCQA/flake8-bugbear#333) because there were several complaints about limitations (PyCQA/flake8-bugbear#329, PyCQA/flake8-bugbear#331, PyCQA/flake8-bugbear#332, #1893 (comment)).
The cause of all these limitations was that the suggested fix (to always add
!r
) was too opinionated and could changed the semantics of the output.As such, this implementation diverges from the original by changing the framing in the documentation and error messages to remove all reference to the problematic suggested fix. Instead, it opts for a more nuanced approach which requires the user to consider their own fix on a case-by-case basis, while also providing an opt out (the user may add a noop to the code).
Test Plan
cargo nextest run
Sources
Implementation inspired by original bugbear implementation
Test cases include all test cases from the original bugbear test file, plus extras
Related/References
ruff
#1893
#2954 (comment)
bugbear
PyCQA/flake8-bugbear#319