Derived from the pyupgrade linter.
Fix is sometimes available.
What it does#
printf-style string formatting.
Why is this bad?#
printf-style string formatting has a number of quirks, and leads to less
readable code than using
str.format calls or f-strings. In general, prefer
str.format and f-strings constructs over
This rule is unable to detect cases in which the format string contains
a single, generic format specifier (e.g.
%s), and the right-hand side
is an ambiguous expression.
For example, given:
value could be a single-element tuple, or it could be a single value.
Both of these would resolve to the same formatted string when using
printf-style formatting, but not when using f-strings: