question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

f-strings: --aggressive mode to rewrite more than basic names

See original GitHub issue

This line is not upgraded:

text = 'TIME {}: {:f} '.format(label, time.time() - t)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
alokcommented, Jun 7, 2018

One possibility would be to add something like an --aggressive flag that unconditionally replaces .format with f-strings, and then users could decide which ones to check in to version control. You could also make it interactive, sort of like isort, but I dunno if that’s worth it.

0reactions
asottilecommented, Jun 7, 2018

I don’t really have any interest in investing time in implementing an interactive mode – pyupgrade is designed to work as a pre-commit hook which is entirely non-interactive.

I’m also unlikely to spend a bunch of time on something I personally wouldn’t use (for instance, I don’t really think much more than a simple name or index belongs in a f-string) – that said, if you want to work on a tested implementation that adds something like an --aggressive-fstrings option, then by all means 😃

I don’t really want to tie down the --pyXX-plus options to levels either, presumably there’s changes that could be made for py36 that are unrelated to fstrings. (and does (hypothetical) --py38-plus=aggressive imply it should more aggressively modify fstrings? probably not)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python 3's f-Strings: An Improved String Formatting Syntax ...
As of Python 3.6, f-strings are a great new way to format strings. Not only are they more readable, more concise, and less...
Read more >
Python f-string
Python f-string tutorial shows how to format strings in Python with f-string. Python f-strings provide a faster, more readable, concise, ...
Read more >
Unreal Engine 5.0 Release Notes
The new mode allows the cut to go through more than one layer or when the cutting curve extends past the edge of...
Read more >
python - Rewriting names (rearranging and modifying strings)
Quick and dirty solution: def rewrite(name): parts = name.split() lastname = parts[-1] if len(parts) > 1: firstname = parts[0] else: return ...
Read more >
Python f-strings: Everything you need to know!
Python f-strings, or formatted string literals, were introduced in Python 3.6. ... to embed expressions inside strings using simple, straightforward syntax.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found