Skip to content

string-dot-format-invalid-format

Pythoncorrectnessno fixdefault: warnpython/ruff

Reports a "...".format(...) call whose string does not parse, such as an unmatched { or }.

Python raises a ValueError (Single '{' encountered in format string) when the line runs. It is usually a literal brace that should have been doubled.

To fix, write {{ and }} for literal braces.

Reported
a = b = c = 1
"{".format(a)
...
"{:{}}".format(a, b)
"{:{:{}}}".format(a, b, c)
"{} {x}".format(*a, **b)
"{}".format(a, *b)
"{0[a].b}".format(a)
"{!}".format(a)
"{0[}".format(a)
python:
lint:
rules:
string-dot-format-invalid-format: warn # off, warn (default), error

Enabled by the presets: python/ruff.

Suppress one line with sudsy-disable-next-line string-dot-format-invalid-format 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 F521 full