printf-string-formatting
What it does
Section titled “What it does”Reports a "..." % x whose format string and values pair up: a tuple with as many values as placeholders, a dict for named fields, or one value for one placeholder.
Why it matters
Section titled “Why it matters”The % operator is the oldest of Python’s three ways to format a string. An f-string or .format puts the value where it is used, and a single value or a tuple that is mistaken for the arguments ("%s" % some_tuple) is a classic bug of %.
To fix, write an f-string, or use .format.
Example
Section titled “Example”...a = b = "x"...
x = "%s" % y
...
...Configuration
Section titled “Configuration”python: lint: rules: printf-string-formatting: warn # off (default), warn, errorEnabled by the presets: python/ruff.
Suppress one line with sudsy-disable-next-line printf-string-formatting 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 | UP031 |
full |