ruff
df313c22 - Avoid infinite loop between `I002` and `PYI025` (#23352)

Commit
63 days ago
Avoid infinite loop between `I002` and `PYI025` (#23352) ## Summary Fixes #20891. When `lint.isort.required-imports` includes `from collections.abc import Set` (unaliased) and PYI025 is enabled, the two rules conflict: I002 inserts the unaliased import, while PYI025 demands it be aliased as `AbstractSet`. This causes an infinite autofix loop ("Failed to converge after 100 iterations"). Rather than patching the import-insertion logic at the rule level, this PR rejects the contradictory configuration at startup in `Configuration::into_settings()`, following the existing pattern established by `conflicting_import_settings()`. The error message explains the conflict and suggests two resolutions: alias the required import as `AbstractSet`, or disable PYI025. ### Prior art PR #21115 took a different approach (modifying `add_required_imports.rs` and `imports.rs` to relax alias matching). As noted in review, the better fix is to "reject this configuration entirely at an earlier stage" since it doesn't make sense to simultaneously require an unaliased import and forbid it. This PR implements that suggestion directly. ## Test plan - 3 unit tests: conflicting config → error, aliased as `AbstractSet` → ok, PYI025 not enabled → ok - Reproduction case: `ruff check --config ruff.toml --unsafe-fixes --fix` now emits a clear configuration error instead of entering the infinite loop - `cargo test -p ruff_workspace` — all 26 tests pass
Author
Parents
Loading