ruff icon indicating copy to clipboard operation
ruff copied to clipboard

[Infinite loop] for pyi file

Open gaborbernat opened this issue 1 year ago • 4 comments

https://github.com/tox-dev/pyproject-api/blob/df39546/src/pyproject_api/_backend.pyi#L1

❯ pre-commit run --all-files
fix end of files.........................................................Passed
trim trailing whitespace.................................................Passed
Validate GitHub Workflows................................................Passed
codespell................................................................Passed
tox-ini-fmt..............................................................Passed
pyproject-fmt............................................................Passed
ruff-format..............................................................Failed
- hook id: ruff-format
- files were modified by this hook

1 file reformatted, 15 files left unchanged

ruff.....................................................................Failed
- hook id: ruff
- exit code: 1
- files were modified by this hook

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 `src/pyproject_api/_backend.pyi`, the rule codes E302, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

src/pyproject_api/_backend.pyi:3:1: E302 Expected 2 blank lines, found 1
Found 105 errors (104 fixed, 1 remaining).
[*] 1 fixable with the --fix option.

gaborbernat avatar Feb 22 '24 02:02 gaborbernat

For now, managed to sidestep the issue with tox-dev/pyproject-api@989d105 (#124)

gaborbernat avatar Feb 22 '24 02:02 gaborbernat

Thanks! I'll take a look at this tonight.

charliermarsh avatar Feb 22 '24 02:02 charliermarsh

Okay, it seems this isn't specific to pyi files but the conflict is between E302 and I001 where I001 enforces at most 1 blank line (depending on what you specified in lines-after-imports and E302 enforces two empty lines.

That's also why I haven't been able to reproduce this behavior when running the above code in an isolated unit test where I001 isn't enabled.

MichaReiser avatar Feb 22 '24 15:02 MichaReiser

I wonder if ruff should fail when conflicting settings are set, or pick a winner and ignore the other rules 🤔

gaborbernat avatar Feb 22 '24 15:02 gaborbernat

@gaborbernat, thank you for all your high-quality issues with code examples. It makes fixing issues so much easier @charliermarsh I'm working on this now. I change the blank line rule to not check empty lines after import statements if isort is enabled.

MichaReiser avatar Feb 23 '24 12:02 MichaReiser