Skip to content

chore: fix ruff import-sort lint drift on main - #50

Merged
artemo-brd merged 2 commits into
mainfrom
fix/ruff-import-sort
Jul 30, 2026
Merged

chore: fix ruff import-sort lint drift on main#50
artemo-brd merged 2 commits into
mainfrom
fix/ruff-import-sort

Conversation

@artemo-brd

Copy link
Copy Markdown
Collaborator

Problem

ruff check on main reports thousands of findings — reproduced on a clean checkout, pre-existing drift, not caused by any recent PR.

Root cause: pyproject.toml declares ruff>=0.1.0 (unpinned) with a [tool.ruff.lint] ignore list but no explicit select. The ignore list (E402, F841) only makes sense for the classic pyflakes/pycodestyle set — without a pinned select, 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

  • Added explicit 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.
  • Ran ruff check --fix after pinning select, so only import reordering was applied (103 files) — no pyupgrade (Optional[X]X | None) or Ruff-specific rewrites (f-string !s/!r conversion, __all__ sorting) snuck in. (An earlier attempt at this fix ran --fix before scoping select, which picked up those extra categories — redone here to be strictly import-sort only.)
  • black --check was already clean on main — no reformatting needed.

Verification

  • ruff check src/ tests/ → clean
  • black --check src/ tests/ → clean, 0 files changed
  • pytest tests/unit → 321 passed, unchanged
  • Diff contains zero Optional[X] -> X | None or f-string conversion rewrites (verified via grep)

Purely mechanical import-sort — no behavioral or type-annotation changes.

- 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.
@artemo-brd
artemo-brd merged commit 8cd389c into main Jul 30, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant