chore(ci): make ruff lint clean so CI passes#1
Conversation
- Configure ruff to ignore deliberate stylistic rules in benchmark/ experiment/test code (E731 lambda assignment, E701/E702 compound one-liners) — these are readable, intentional closures and tight timing blocks, not bugs. - Exclude notebooks/, paper/, results/ from linting (demo cell code and build artifacts, not the importable library surface). - Apply ruff autofixes: drop unused imports, split multi-import lines. - Remove a dead local in test_best_so_far_only_decreases (F841). `ruff check .` now passes with no errors.
Reviewer's GuideUpdates Ruff configuration and code style to make Flow diagram for updated Ruff lint configuration in CIflowchart LR
CI[CI lint job]
Ruff[ruff check .]
Src[Library and scripts]
Excl[Excluded dirs
notebooks, paper, results]
Rules[Ruff lint rules
ignore E731,E701,E702]
Status[Lint status
all checks passed]
CI --> Ruff
Ruff --> Src
Ruff -. skips .-> Excl
Ruff --> Rules
Ruff --> Status
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Review limit reached
More reviews will be available in 43 minutes and 39 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (17)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Instead of globally ignoring E731/E701/E702, consider using
per-file-ignoresor path-specific sections so that these stylistic relaxations only apply to the benchmark/experiment/test scripts and not to the core library code. - The
extend-excludecomment only mentions notebooks but the pattern also excludespaperandresults; consider updating the comment or narrowing the pattern so it accurately reflects what is being excluded.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Instead of globally ignoring E731/E701/E702, consider using `per-file-ignores` or path-specific sections so that these stylistic relaxations only apply to the benchmark/experiment/test scripts and not to the core library code.
- The `extend-exclude` comment only mentions notebooks but the pattern also excludes `paper` and `results`; consider updating the comment or narrowing the pattern so it accurately reflects what is being excluded.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
conftest.py imports matplotlib for the headless Agg backend, and the suite exercises the benchmark harness (plots, stats, HPO baselines, CMA-ES). Installing only .[dev] left those deps missing, so collection failed with ModuleNotFoundError. Install .[dev,benchmark].
There was a problem hiding this comment.
Pull request overview
This PR restores a green Ruff lint job after the v0.3.0 release by aligning the Ruff configuration with the repo’s existing benchmarking/experiment style and applying straightforward autofixes (unused imports, import splitting, and notebook cell metadata normalization). It’s a maintenance-focused change that should not affect runtime behavior, aside from a small dead-code cleanup in one test.
Changes:
- Update
pyproject.tomlRuff settings to exclude non-library directories and ignore select style-only rules (E701/E702/E731). - Remove unused imports across tests/scripts/library modules to satisfy Ruff.
- Normalize notebooks by adding cell
idfields and splitting multi-import statements.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
tests/test_vectorized_fitness.py |
Removes unused pytest import. |
tests/test_hpo_baselines.py |
Removes unused torch import. |
tests/test_experiments_registry.py |
Removes unused torch import. |
tests/test_benchmark_plots_report.py |
Removes unused numpy import. |
tests/test_benchmark_budget.py |
Removes an unused local (wrapped) in a test. |
swarmtorch/experiments/runner.py |
Removes unused RunResult import. |
swarmtorch/benchmark/report.py |
Removes unused Any import. |
swarmtorch/benchmark/gpu_vs_numpy.py |
Removes unused SYNTHETIC_FUNCTIONS import. |
swarmtorch/benchmark/budget.py |
Removes unused Any import. |
scripts/run_hpo.py |
Removes unused BaselineHPO import. |
scripts/run_hpo_real.py |
Removes unused Any import. |
scripts/run_feature_selection.py |
Removes unused Any import. |
scripts/run_ablations.py |
Removes unused PAPER_ALGORITHMS import. |
pyproject.toml |
Adjusts Ruff lint configuration (excludes + ignore list). |
notebooks/kaggle_full_benchmark.ipynb |
Adds cell IDs and splits multi-imports. |
notebooks/gpu_vs_numpy.ipynb |
Adds cell IDs and splits multi-imports. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
What
Gets the CI lint job green. After the v0.3.0 release the
ruff check .step was failing on 35 findings; this resolves all of them.How
E731lambda assignment — used for one-line closures (plain = lambda: F.mse_loss(model(x), y)).E701/E702compound one-liners — tight timing blocks (t0 = ...; r = s.search(); wall = ...).notebooks/(demo cell code),paper/,results/(build artifacts).import os, sys→ one per line). Notebooks also gained standard nbformat cellidfields.wrappedlocal intest_best_so_far_only_decreases(F841).Verification
ruff check .→ All checks passed!pytest tests/test_benchmark_budget.py→ 7 passed.Closes HAL-302
Summary by Sourcery
Align linting configuration and code style with Ruff to restore a clean CI lint job without changing runtime behavior.
Bug Fixes:
Enhancements: