Skip to content

FURB129 fix should add spaces between tokens #17683

@dscorbett

Description

@dscorbett

Summary

The fix for readlines-in-for (FURB129) can introduce a syntax error when .readlines() is followed immediately by a keyword without white space.

$ cat >furb129.py <<'# EOF'
with open("furb129.py") as f:
    print([line for line in f.readlines()if True])
# EOF

$ ruff --isolated check --select FURB129 --unsafe-fixes --diff furb129.py 2>&1 | grep error:
error: Fix introduced a syntax error. Reverting all changes.

Version

ruff 0.11.7 (f7b4851 2025-04-24)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions