-
-
Notifications
You must be signed in to change notification settings - Fork 186
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
constant fold literals in f", .format and % formatting #353
Comments
It might also be good to hit the explicit str concat |
this also applies to numeric literals, I just noticed pyupgrade apply this change: - "hostname": "{}:{}".format(dc, 636),
+ "hostname": f"{dc}:{636}", but I'd expect |
Also found this issue when upgrading a codebase with -BROKER_URL = "{redis}/{db}".format(redis=REDIS_URL, db=0)
+BROKER_URL = f"{REDIS_URL}/{0}" |
Different issue but possibly similar fix: f"{repr(x)}" Could be converted to: f"{x!r}" These happen to be common from |
I have a project with a bunch of tests that check logging messages (with
testfixtures.LogCapture
) they look like this:log.check((module.__name__, "INFO", "the user {user!r} did a bad".format(user=u"user")))
The reason - because the repr of u"user" is different on py3 and py2. I'd like to see
pyupgrade --py3-plus
rewrite them all to:log.check((module.__name__, "INFO", "the user 'user' did a bad"))
The text was updated successfully, but these errors were encountered: