Skip to content

[Infinite loop] Parser error with I002 (required imports) and F401 (unused import) #12458

@AA-Turner

Description

@AA-Turner

I ran into a fun error:

PS> ruff -V
ruff 0.5.4
PS> ruff check --isolated --select I002,F401 --fix --unsafe-fixes --config "lint.isort.required-imports=['from path import Path']" bug.py

error: Failed to converge after 100 iterations.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BInfinite%20loop%5D

...quoting the contents of `bug.py`, the rule codes I002, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

bug.py:1:1: I002 Missing required import: `from path import Path`
Found 101 errors (100 fixed, 1 remaining).
[*] 1 fixable with the --fix option.

PS> type bug.py
_ = 'Path'

The content of bug.py is "_ = 'Path'\n". If you remove the assignment, all works (one imagines as the string is parsed as a docstring).

_ = 'Path'

The error exists going back at least as far as 0.2.2 (0.2.1 gives errors with mixing --isolated and --config).

I can't see any similar issues, but if I've missed one please close this!

A

Metadata

Metadata

Assignees

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