-
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
printf-string-formatting
(UP031
) - fix should f-string instead of str.format
#11332
Comments
We iteratively apply fixes until the source code is stable so if you've select both $ ruff check --unsafe-fixes --fix --no-cache --diff --select=UP031,UP032 src/autofix.py
--- src/autofix.py
+++ src/autofix.py
@@ -1,2 +1,2 @@
foo = "foo"
-"%s" % (foo,)
+f"{foo}"
Would fix 2 errors. Can you tell me how are you running |
I think astral-sh/ruff-vscode#451 is related. For this specific case, maybe we could prioritize |
Oh, but that might not be possible because |
Yeah this is roughly by design though I understand why it's not ideal in an editor. IIRC we only support translating |
Maybe it would be a good idea to merge UP031 and UP032. I don't know if ruff has a minimum version, but f-strings exist since Python 3.6 🤔 |
@autinerd |
when both
UP031
andUP032
are enabled, the fix forUP031
causesUP032
:after applying the quick fix:
https://play.ruff.rs/c4a825b4-12e5-4479-9167-c0f4388a17c2
this means i have to apply 2 fixes to get to the correct code. it would be nice if
UP031
suggested f strings instead.The text was updated successfully, but these errors were encountered: