Skip to content

FURB129 fix fails when the variable is parenthesized #18231

@dscorbett

Description

@dscorbett

Summary

The fix for readlines-in-for (FURB129) fails because of a syntax error when the file variable is parenthesized.

$ cat >furb129.py <<'# EOF'
with open("furb129.py") as f:
    for line in (f).readlines():
        pass
# EOF

$ ruff --isolated check furb129.py --select FURB129 --unsafe-fixes --diff

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 `furb129.py`, the rule codes FURB129, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

Version

ruff 0.11.10 (b35bf8a 2025-05-15)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfixesRelated to suggested fixes for violationshelp wantedContributions especially welcome

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions