-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
ruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
IIUC, these two expressions are exactly equivalent:
f"{str(x)}" # (1)
f"{x}" # (2)
The str is superfluous in (1). But instead of RUF010 removing the str call, instead it autofixes to f"{x!s}"-- but the !s here is still superfluous-- the only time it makes sense to use !s is if there is an additional format specifier, e.g. f"{x!s:20}" (in this case str is applied before the format specifier, whereas without !s it is applied after the format specifier).
So IMO RUF010 should remove str() unless there is a format specifier, in which case it converts to !s.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
ruleImplementing or modifying a lint ruleImplementing or modifying a lint rule