-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violations
Description
Summary
The percent-format-extra-named-arguments (F504) fix can change behavior if the extra args have side effects. It should probably be an always unsafe fix, or only safe if the args being removed are only literals.
playground
PS ~\Desktop\New_folder\ruff>Get-Content issue.py
"Hello, %(name)s" % {"greeting": print(1), "name": "World"}PS ~\Desktop\New_folder\ruff>py issue.py
1
PS ~\Desktop\New_folder\ruff>uvx ruff check issue.py --isolated --select F
issue.py:1:1: F504 [*] `%`-format string has unused named argument(s): greeting
|
1 | "Hello, %(name)s" % {"greeting": print(1), "name": "World"}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F504
|
= help: Remove extra named arguments: greeting
Found 1 error.
[*] 1 fixable with the `--fix` option.PS ~\Desktop\New_folder\ruff>uvx ruff check issue.py --isolated --select F --fix
Found 1 error (1 fixed, 0 remaining).
PS ~\Desktop\New_folder\ruff>Get-Content issue.py
"Hello, %(name)s" % {"name": "World"}PS ~\Desktop\New_folder\ruff>py issue.py
This also applies to string-dot-format-extra-named-arguments (F522) playground
This also applies to string-dot-format-extra-positional-arguments (F523) playground
Version
ruff 0.12.0 (87f0feb 2025-06-17) + playground
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violations