Skip to content
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

Use f-string instead of string.format #20

Open
3 tasks
Tadaboody opened this issue Dec 3, 2018 · 1 comment
Open
3 tasks

Use f-string instead of string.format #20

Tadaboody opened this issue Dec 3, 2018 · 1 comment
Labels
smell A new smell to report and fix

Comments

@Tadaboody
Copy link
Owner

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)
@Tadaboody Tadaboody added the smell A new smell to report and fix label Dec 5, 2018
@Tadaboody
Copy link
Owner Author

Can look at https://github.com/asottile/pyupgrade which already implemented this for """insparation"""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
smell A new smell to report and fix
Projects
None yet
Development

No branches or pull requests

1 participant