Skip to content

percent-format-mixed-positional-and-named

Pythoncorrectnessno fixdefault: warnpython/ruff

Reports a % format that has both positional placeholders (%s) and named ones (%(a)s).

A format takes its values from a tuple or from a mapping, not both. Python raises a TypeError at run time.

To fix, use only named placeholders with a dict, or only positional ones with a tuple.

Reported
a = b = c = 1
...
"%s %(x)s" % a
...
python:
lint:
rules:
percent-format-mixed-positional-and-named: warn # off, warn (default), error

Enabled by the presets: python/ruff.

Suppress one line with sudsy-disable-next-line percent-format-mixed-positional-and-named 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 F506 full