-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[flake8-bugbear
] Implement quoted-fstring-value
(B907
)
#11977
base: main
Are you sure you want to change the base?
Conversation
It seems like the check in bugbear suffered from a lot of false positives (and hence was moved to the opinionated section). Do you know how many of those are present in the implementation here? What are the limitations of the rule? |
This rule has all of the same limitations as the original, since it is the same algorithm. All of the limitations that I have seen suggested fall under the same issue: this rule may suggests a fix (adding Under the current framing (that adding However, the real cause of both of these issues is the original framing that the proposed fix (adding For this reason, I originally tried to word the message as a suggestion for the user to consider if this is a problem on a case-by-case basis instead of as something that the user must fix. I think this still requires more rewording in order to make this clearer. edit: rewritten in order to hopefully improve clarity |
I have changed the framing around the rule by changing the suggested fix. I believe that this overcomes all previously suggested limitations, as discussed above. Summary: Open questions: |
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