| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
FWIW I prefer keeping the leading f's when some part of the implicitly concatenated string uses formatting (and will intentionally add them), to make the string prefixes aligned... |
Sorry, something went wrong.
|
I have mixed feelings. On one hand I agree with @anntzer that keeping the prefixes lined up in helps keep the code readable. On the other hand I have had a linter catch "I meant to make this an f-string but forget the f" on a couple of occasions. A suggestion that I think everyone will be against, we could use an explicit u on non-f-string strings in these stacks (it is legal https://docs.python.org/3.10/reference/lexical_analysis.html#string-and-bytes-literals) aligned and the linters happy. |
Sorry, something went wrong.
|
I would rather fix the linters to allow (perhaps as an option) the "there's an f just to align with another f in the implicitly concatenated string". For example, pylint seems smart enough to not emit warnings in that case (while warning for unnecessary f's if there's no interpolation anywhere). Also, note that what you mention seems to be the opposite case (catching a missing f, not an unneeded one). |
Sorry, something went wrong.
|
I tend to agree with @anntzer. This is a very general styling topic. Are we aware of any recommendations/best practice of other libraries? |
Sorry, something went wrong.
|
I'll close, but feel free to reopen if we think this is really needed. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
No need for an f-string if no formatting is done.
As I stumbled upon a line that was mentioned in #21959 I also fixed that.
Closes #21968 (except that there is no test for it here).
PR Checklist
Tests and Styling
Documentation