Skip to content

percent-format-expected-sequence

Pythoncorrectnessno fixdefault: warnpython/ruff

Reports a % format that has several positional placeholders applied to a dict.

Positional placeholders take one value each from a tuple. A dict is taken as one value, so with two or more placeholders Python raises TypeError: not enough arguments for format string.

To fix, pass a tuple, or name the placeholders (%(a)s).

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

Enabled by the presets: python/ruff.

Suppress one line with sudsy-disable-next-line percent-format-expected-sequence 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 F503 full