-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violations
Description
Summary
Consider the following code:
if __name__ == "__main__":
number = 0
string = "{}".format(number := number + 1)
print(string)It executes successfully and prints 1.
When I run ruff, it returns
bad_ruff.py:3:14: UP032 [*] Use f-string instead of `format` call
|
1 | if __name__ == "__main__":
2 | number = 0
3 | string = "{}".format(number := number + 1)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032
4 | print(string)
|
= help: Convert to f-string
When I run ruff check --fix bad_ruff.py, the resulting code is invalid and results in ValueError:
if __name__ == "__main__":
number = 0
string = f"{number := number + 1}"
print(string)Version
ruff 0.11.13 (5faf72a 2025-06-05)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violations