flynt

raw JSON →
1.0.6 verified Fri May 01 auth: no python

A CLI tool to automatically convert a Python project's %-formatted strings (like '%s' % var) and .format() calls to f-strings. Current version 1.0.6, stable, low release cadence. Requires Python >=3.9.

pip install flynt
error flynt: error: unrecognized arguments: --line-length 80
cause The --line-length option was removed in a previous version.
fix
Remove --line-length from your command; flynt no longer supports line length control.
error TypeError: fstringify() got an unexpected keyword argument 'transform_multiline_fstrings'
cause The argument was renamed or removed in a newer version of flynt.
fix
Check the API docs; use the correct argument name, e.g., 'multiline' instead.
gotcha flynt only works on literal string expressions, not on strings stored in variables or computed at runtime. It cannot convert %-formatting inside non-literal strings.
fix Ensure the strings you want to convert are explicit string literals in the source code.
gotcha flynt will modify files in-place by default. Without --dry-run, it overwrites source files, which can lead to loss of original formatting.
fix Always run with --dry-run first to preview changes: flynt --dry-run <file_or_dir>
breaking flynt 1.0.6 drops Python 3.8 support; requires Python >=3.9.
fix Upgrade Python to 3.9+ or pin flynt to <1.0.6 if Python 3.8 is required.
gotcha flynt may introduce syntax errors if the original string contains complex nested expressions or escaped quotes. Always verify the output.
fix Run tests after conversion. Use --verbose to inspect changed files.
deprecated The --line-length option was removed in an earlier version; there is no replacement.
fix Remove --line-length from command line if used.

Basic usage: convert a single string literal to f-string.

import flynt
# flynt is a CLI tool; to run programmatically:
from flynt import fstringify
fstringify('"%s" % "hello"')