good_smell
good_smell copied to clipboard
Use f-string instead of string.format
New smell
Smelly code
"a={},b={}".format(a,b)
Fixed code
f"a={a},b={b}"
Potential gotchas:
- [ ] warn only on py3.6+
- [ ] if the expression has quotes in it make sure to alternate single quotes
''and double quotes"" - [ ] Don't warn if the formatted string isn't called directly (if the string is waiting for later)
Can look at https://github.com/asottile/pyupgrade which already implemented this for """insparation"""