Skip to content

f-string

Pythonstyleno fixdefault: offpython/ruff

Reports a "...".format(...) call on a string literal whose fields all name an argument.

An f-string puts the expression where it is shown, so the reader does not look from the field to the argument list and count positions. It is also the faster form.

To fix, write an f-string.

Reported
...
...
x = "{}".format(y)
...
python:
lint:
rules:
f-string: warn # off (default), warn, error

Enabled by the presets: python/ruff.

Suppress one line with sudsy-disable-next-line f-string in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
ruff UP032 full