-
Notifications
You must be signed in to change notification settings - Fork 2k
Form feed before try makes the RUF072 fix introduce a syntax error #24373
Copy link
Copy link
Closed
Description
Summary
The useless-finally (RUF072) fix introduces a syntax error when the try line has a form feed. Example:
$ printf '\ftry:\n 1\nfinally:\n pass\n' | ruff --isolated check - --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 `-`, the rule codes RUF072, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!
try:
1
finally:
pass
error[RUF072]: Empty `finally` clause
--> -:3:1
|
1 | try:
2 | 1
3 | / finally:
4 | | pass
| |________^
|
help: Remove the `finally` clause
- try:
- 1
- finally:
- pass
1 + 1
Found 1 error.
[*] 1 fixable with the `--fix` option.Version
ruff 0.15.9 (724ccc1 2026-04-02)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels