-
Notifications
You must be signed in to change notification settings - Fork 2k
Form feeds make the RUF072 fix introduce syntax errors #24246
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violations
Description
Summary
The useless-finally (RUF072) fix introduces a syntax error when it dedents a try block some but not all of whose lines begin with form feeds.
$ printf 'try:\n\f 1\n 2\nfinally:\n pass\n' >ruf072.py
$ ruff --isolated check ruf072.py --select RUF072 --preview --fix
error: Fix introduced a syntax error. Reverting all changes.
This indicates a bug in Ruff. If you could open an issue at:
https://github.com/astral-sh/ruff/issues/new?title=%5BFix%20error%5D
...quoting the contents of `ruf072.py`, the rule codes RUF072, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!
error[RUF072]: Empty `finally` clause
--> ruf072.py:4:1
|
2 | 1
3 | 2
4 | / finally:
5 | | pass
| |________^
|
help: Remove the `finally` clause
- try:
- 1
1 + 1
2 | 2
- finally:
- pass
Found 1 error.
[*] 1 fixable with the `--fix` option.Version
ruff 0.15.8 (c2a8815 2026-03-26)
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