When the fix for string-dot-format-extra-positional-arguments (F523) removes a string’s format method call, it can change the program’s behavior. If the string contains a double brace like {{, it originally represents an escape sequence for a single brace like {, but with the method call removed it literally represents a double brace. If the string contains an unset field name, removing the method call suppresses the expected KeyError.
$ ruff --version
ruff 0.9.2
$ cat f523.py
print("{{".format("!"))
print("{x}".format("!"))
$ python f523.py
{
Traceback (most recent call last):
File "f523.py", line 2, in <module>
print("{x}".format("!"))
^^^^^^^^^^^^^^^^^
KeyError: 'x'
$ ruff --isolated check --fix --select F523 f523.py
Found 2 errors (2 fixed, 0 remaining).
$ python f523.py
{{
{x}
When the fix for
string-dot-format-extra-positional-arguments(F523) removes a string’sformatmethod call, it can change the program’s behavior. If the string contains a double brace like{{, it originally represents an escape sequence for a single brace like{, but with the method call removed it literally represents a double brace. If the string contains an unset field name, removing the method call suppresses the expectedKeyError.