Repository navigation
Replace black/flake8/isort with ruff for lint + format - #67
Merged
Merged
Conversation
- Add ruff.toml: line-length 100 (matches the old flake8 setting), select E/F/W/I (I replaces isort), and a per-file F401 ignore for __init__.py (previously only passed on the CI flake8 command line, so pre-commit never enforced it). Exclude *.ipynb and *.md from `ruff format` -- black never touched notebooks, and ruff's markdown support reformats embedded Python code fences in the docs, which is out of scope here. - Delete setup.cfg (only held the flake8 config). - .pre-commit-config.yaml: drop black/flake8/isort hooks, add astral-sh/ruff-pre-commit (ruff-check --fix, ruff-format); bump the stale pre-commit-hooks pin (v2.3.0 -> v6.0.0). - CI: replace the flake8 lint step with `ruff check .`, and add a new `ruff format --check .` step -- CI previously never checked formatting at all (black/isort only ran via pre-commit). - tests/requirements.txt: flake8 -> ruff. - Reformat all Python sources with `ruff format` (mostly re-wrapping lines that black had wrapped at 88 chars, now allowed up to 100) and apply `ruff check --fix` (clean; no violations beyond formatting). - README: swap the "Code Style: Black" badge for the official Ruff badge; also point the Colab links at `main` instead of `master` (the repo has no master branch -- these only worked via GitHub's redirect). - CLAUDE.md: update the Commands/gotcha text that referenced flake8, black, isort, and setup.cfg; also correct a stale "Python >= 3.9" note that no longer matched setup.py/CI (>=3.10). Dependency updates beyond the ruff swap itself: pre-commit-hooks v2.3.0 -> v6.0.0. Core runtime deps (gymnasium, numpy, pandas, matplotlib, pygame, shapely) were already bumped and verified in the immediately preceding commit (b07257b); nothing there is newly outdated except transitive CUDA/nvidia/pydantic-core pins and gymnasium 1.2.2 (pinned by ray[rllib], already inside setup.py's >=0.29.1,<2.0 range), so those were left alone. Verified: pytest (11 passed), pytest --nbmake examples/test.ipynb (1 passed), and pre-commit run --all-files (clean) all pass locally. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X4RPjRuz4qpmA9XFRkKKRM
The old "PyPI" badge was actually the python-publish.yml workflow-status badge, which only runs on release tags, so it reads as stale/broken most of the time. Replace it with the actual PyPI version badge (links to the package's PyPI page instead of a CI workflow run). Also add a License badge since none existed despite the project being MIT-licensed. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X4RPjRuz4qpmA9XFRkKKRM
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.
Summary
ruff.toml:line-length = 100(matches the previous flake8 setting),select = ["E", "F", "W", "I"](Ireplaces isort), and a per-fileF401ignore for__init__.py(previously only passed on the CI flake8 command line via--per-file-ignores, so pre-commit never actually enforced it).*.ipynband*.mdare excluded fromruff format— black never touched notebooks, and ruff's markdown support would otherwise reformat the Python code fences embedded in the docs, which is out of scope here.setup.cfg(it only held the flake8 config)..pre-commit-config.yaml: drop the black/flake8/isort hooks, addastral-sh/ruff-pre-commit(ruff-check --fix,ruff-format); also bumped the stalepre-commit-hookspin (v2.3.0→v6.0.0) while touching this file..github/workflows/python-package.yml): replace the "Lint with flake8" step withruff check ., and add a newruff format --check .step. This is a real behavior change, not just a swap — CI previously never checked formatting at all; black/isort only ran locally via pre-commit.tests/requirements.txt:flake8→ruff.ruff format(mostly re-wrapping lines that black had wrapped at 88 chars, now allowed up to 100 to match the lint config) and ranruff check --fix(clean — no violations beyond formatting).README badges
python-publish.ymlworkflow-status badge, which only runs on release tags, so it reads stale/broken most of the time. Replaced with a real PyPI version badge linking to the package's PyPI page.maininstead ofmaster— the repo has nomasterbranch, so those only ever worked via GitHub's redirect.Dependency updates
Beyond the ruff swap itself:
pre-commit-hooksv2.3.0→v6.0.0. I checkeduv pip list --outdated; core runtime deps (gymnasium, numpy, pandas, matplotlib, pygame, shapely) were already bumped and verified in the immediately preceding commit (b07257b), and nothing there is newly outdated except transitive CUDA/nvidia/pydantic-core pins andgymnasium1.2.2 (pinned exactly byray[rllib], already inside setup.py's>=0.29.1,<2.0range) — so those were left alone.Not included: the stuck-CI ruleset issue
Separately reported (and diagnosed, but not fixed here — it's a repo Settings change, not a code change): the
mainbranch ruleset requires status checkbuild (ubuntu-latest, 3.9), but the CI matrix hasn't run 3.9 since an earlier commit (now 3.10–3.13). That context can never be reported, so every PR — including this one — sits "Expected — Waiting for status to be reported" forever. Fix is to update the ruleset's required checks to swap3.9for3.13(Settings → Rules → Rulesets → main).Verification
pytest— 11 passedpytest --nbmake examples/test.ipynb— 1 passedpre-commit run --all-files— cleanruff check ./ruff format --check .— cleanruff checkflags them (E501, I001) before relying on it.🤖 Generated with Claude Code