chore: fix ruff import-sort lint drift on main - #50
Merged
Conversation
- pyproject.toml: pin tool.ruff.lint select to [E4, E7, E9, F, I] explicitly, BEFORE running any autofix. Without an explicit select, an unpinned 'ruff>=0.1.0' silently picks up its current default rule set, which now includes plugin categories (datetimez, simplify, pyupgrade, bugbear, etc.) never intended by this repo's ignore list (which only ever suppressed E402/F841). This made 'ruff check' in CI fail with thousands of findings unrelated to any recent change. - ruff check --fix: sort/organize imports across src/ and tests/ (103 files), scoped strictly to E4/E7/E9/F/I — purely mechanical import reordering. No pyupgrade (Optional[X] -> X | None) or RUF (f-string conversion, __all__ sorting) rewrites, since those categories were never selected. Verified: ruff check clean, black --check clean (no drift found on main), full unit suite (321 tests) passes unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ruff checkonmainreports thousands of findings — reproduced on a clean checkout, pre-existing drift, not caused by any recent PR.Root cause:
pyproject.tomldeclaresruff>=0.1.0(unpinned) with a[tool.ruff.lint]ignorelist but no explicitselect. The ignore list (E402,F841) only makes sense for the classic pyflakes/pycodestyle set — without a pinnedselect, newer ruff resolves its own broader default, pulling in categories (datetimez, simplify, pyupgrade, bugbear...) never intended by this repo, on top of never-enforced import-sort (I001) findings across the codebase.Fix
select = ["E4", "E7", "E9", "F", "I"]to[tool.ruff.lint]— restores the classic error/pyflakes/import-sort scope the ignore list was written for, insulated from ruff version drift going forward.ruff check --fixafter pinningselect, so only import reordering was applied (103 files) — no pyupgrade (Optional[X]→X | None) or Ruff-specific rewrites (f-string!s/!rconversion,__all__sorting) snuck in. (An earlier attempt at this fix ran--fixbefore scopingselect, which picked up those extra categories — redone here to be strictly import-sort only.)black --checkwas already clean onmain— no reformatting needed.Verification
ruff check src/ tests/→ cleanblack --check src/ tests/→ clean, 0 files changedpytest tests/unit→ 321 passed, unchangedOptional[X] -> X | Noneor f-string conversion rewrites (verified via grep)Purely mechanical import-sort — no behavioral or type-annotation changes.