Skip to content

percent-format-positional-count-mismatch

Pythoncorrectnessno fixdefault: warnpython/ruff

Reports a % format whose number of placeholders differs from the number of values in the tuple.

Python raises a TypeError when the line runs: not enough arguments for format string with too few values, not all arguments converted during string formatting with too many.

To fix, make the two counts the same.

Reported
...
"%s %s" % {"x": 1}
...
"%s %s" % (a,)
"%*s" % {"x": 1}
"%s" % a
"%s %s" % (*a,)
"%(x)s" % {"x": 1, **a}
...
python:
lint:
rules:
percent-format-positional-count-mismatch: warn # off, warn (default), error

Enabled by the presets: python/ruff.

Suppress one line with sudsy-disable-next-line percent-format-positional-count-mismatch 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 F507 full