f-strings: --aggressive mode to rewrite more than basic names
See original GitHub issueThis line is not upgraded:
text = 'TIME {}: {:f} '.format(label, time.time() - t)
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.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)