This is an alpha release. Do NOT use on uncommitted code!
fstringify
is a command line tool to automatically convert a project's Python code from old "%-formatted" strings into Python 3.6+'s "f-strings".
Here's a complete diff running it against flask.
I mainly wanted an excuse to play with the built-in AST and tokenze modules. That said, f-strings are really cool. To quote Joanna Jablonski's great f-string guide:
Not only are they more readable, more concise, and less prone to error than other ways of formatting, but they are also faster!
fstringify
can be installed by running pip install fstringify
. It requires
Python 3.6.0+ to run and effectively turns the code it runs on into Python 3.6+,
since 3.6 is when "f-strings" were introduced.
To run: fstringify {source_file_or_directory}
usage: fstringify [-h] [--verbose | --quiet] [--version] src
fstringify 0.x.x
positional arguments:
src source file or directory
optional arguments:
-h, --help show this help message and exit
--verbose run with verbose output
--quiet run without output
--version show version and exit