percent-format-expected-mapping
What it does
Section titled “What it does”Reports a % format that has named placeholders (%(a)s) applied to a tuple, list or set.
Why it matters
Section titled “Why it matters”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.
Example
Section titled “Example”..."%(x)s" % (a,)...Configuration
Section titled “Configuration”python: lint: rules: percent-format-expected-mapping: warn # off, warn (default), errorEnabled 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.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| ruff | F502 |
full |