Skip to content

style: lint and format legacy top-level code - #6

Merged
YongboYu merged 1 commit into
mainfrom
chore/lint-legacy-code
Jul 27, 2026
Merged

style: lint and format legacy top-level code#6
YongboYu merged 1 commit into
mainfrom
chore/lint-legacy-code

Conversation

@YongboYu

Copy link
Copy Markdown
Owner

Third and final follow-up after the ER evaluation merge. Brings the legacy top-level code (models/, preprocessing/, utils/, train.py, scripts/preprocess_logs.py) up to the ruff standard adopted in #5, and removes it from the pre-commit exclude so it stays enforced going forward.

What changed

The diff is large but behavior-preserving — it's dominated by deterministic ruff-format reflow of files that were never formatted before. The substantive fixes:

Rule Fix Count
B904 chain re-raised exceptions with from e 8
B023 bind optuna/apply lambda loop vars as default args (false positives — callables consumed synchronously) 5 lambdas
F841 remove dead local assignments (unused timers/containers) 8
B905 explicit strict= on zip() 14
E402 drop duplicate mid-file pandas/pathlib imports 2
RUF002 ambiguous ×x in docstrings 3
auto imports, whitespace, PEP 585/604 typing, f-strings, comprehensions ~690

Verification

  • ruff check .all checks pass (whole repo).
  • pre-commit run --all-files — all hooks pass.
  • Every modified file py_compiles cleanly.

After this lands, the entire codebase (not just src/) is linted by CI.

Brings the legacy top-level code (models/, preprocessing/, utils/, train.py,
scripts/preprocess_logs.py) up to the ruff standard adopted in the CI/tooling
alignment, and removes it from the pre-commit exclude so it stays enforced.

- Auto-fixed + formatted with ruff (imports, whitespace, PEP 585/604 typing
  modernization, f-string conversions, comprehensions).
- B904: chain re-raised exceptions with `from e` (8 sites).
- B023: bind optuna/apply lambda loop variables as default args — these were
  false positives (the callables are consumed synchronously within the loop),
  now made explicit and warning-free.
- F841: remove dead local assignments (unused timers, containers, node_map).
- B905: add explicit `strict=` to zip() calls.
- E402: drop duplicate mid-file pandas/pathlib imports (already at top).
- RUF002: replace ambiguous MULTIPLICATION SIGN with 'x' in docstrings.
- Assorted small ruff fixes (SIM, RUF, naming).

Behavior is unchanged; the diff is dominated by deterministic ruff-format
reflow of previously unformatted files.
@YongboYu
YongboYu merged commit 630e393 into main Jul 27, 2026
6 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