Skip to content

percent-format-expected-mapping

Pythoncorrectnessno fixdefault: warnpython/ruff

Reports a % format that has named placeholders (%(a)s) applied to a tuple, list or set.

Named placeholders look their value up in a mapping. With a tuple, Python raises TypeError: format requires a mapping when the line runs.

To fix, pass a dict, or use positional placeholders.

Reported
...
"%(x)s" % (a,)
...
python:
lint:
rules:
percent-format-expected-mapping: warn # off, warn (default), error

Enabled by the presets: python/ruff.

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