#28672·ruff

`explicit-f-string-type-conversion (RUF010)` incorrectly suggested when string type is supplied

Author: mcrumillerCreated Sep 17, 2026Updated Sep 17, 2026

Summary

When an f-string specifies the string type, str() is sometimes required if the variable is not already a string, else the expression errors:

x = 3
f"{str(x):10s}"  # Ruff warning: Use explicit conversion flag
f"{x:10s}"       # ValueError: Unknown format code 's' for object of type 'int'

Ruff should not make the suggestion when x is not a string and the string type is specified via :*s in the f-string type specifier.

Version

0.16.8