Add ruff + pre-commit (format + E,F,I) — fixes #28#27
Conversation
There was a problem hiding this comment.
Code Review
This pull request standardizes the codebase by adopting ruff for linting and formatting, adding pre-commit hooks, and updating contribution guidelines. The changes consist of extensive formatting adjustments across all modules and tests to ensure consistency. Feedback focuses on improving code quality by removing an empty TYPE_CHECKING block and several unused variables that were unnecessarily preserved with linter suppression tags.
…mpty TYPE_CHECKING Per gemini-code-assist review on aganthos#27: - clawloop/environments/openclaw.py: drop empty `if TYPE_CHECKING: pass` block and unused TYPE_CHECKING import - tests/test_curator_lightweight.py: invoke `curator.consolidate(pb)` directly; drop unused `report =` binding - tests/test_otel_exporter.py: delete `original_span_kind` / `original_kind_agent` assignments (never read) - tests/test_local_evolver.py: remove unused `playbook = Playbook()` and its now-dead import - tests/test_harbor_env.py: call `_make_env()` bare; drop unused `env` - examples/openclaw_demo_remote.py: drop unused `episodes: list[Episode] = []` (captured list is built a few lines below) Net: 12 lines deleted, no F841 noqa suppressions remain.
|
Thanks for picking this up. I refreshed the tracking issue as #28 and updated the PR metadata so this closes the live issue. The commits and contribution stay yours. |
|
Hi @kiranannadatha8, @tianyibigdata pleae also take a look |
Hey @kiranannadatha8, thank you for your contribution. Could you plz address the following issues:
|
Adds a parallel `lint` job that runs: - ruff check --select E,F,I clawloop tests examples - ruff format --check clawloop tests examples Version is pinned via the `[dev]` extra (ruff>=0.4,<0.5), which matches the pre-commit v0.4.4 hook pin so local and CI agree. Closes the "CI lint job" follow-up called out as out-of-scope in the PR body; addresses reviewer request on aganthos#27.
|
Thanks for the review @bordeauxred @tianyibigdata. Status on the three items: 1. Gemini review comments — resolved in f080002:
No 2. GitHub Workflow integration — added in 60f7e26. New parallel
Version lock chain: pre-commit pins 3. Squash merge — happy to either (a) leave the 4 commits and let you use GitHub's "Squash and merge" button, or (b) force-push a single squashed commit if you'd prefer the branch history clean before merge. LMK which you'd like. |
thx, saw the gemini fix. one last thing, could you plz add the ruff and its flags to the precommit and call the following in the CI? plz force push the squahsed commit. |
60f7e26 to
87005b8
Compare
|
Done, @tianyibigdata: Pre-commit is now the source of truth. - id: ruff
args: [--fix, --select, "E,F,I"]
- id: ruff-formatCI lint job calls pre-commit directly: - run: pip install -e ".[dev]"
- name: Run pre-commit hooks
run: pre-commit run --all-filesNo more duplicate flag config between Squashed — the 4 PR commits + the two follow-up fixes collapsed into a single commit |
87005b8 to
3871ff9
Compare
|
Rebased onto latest What moved in upstream main since fork:
How I resolved:
Lint violations surfaced by the new config (12 total, all fixed minimally):
Verified locally:
PR now shows 1 commit, |
| submodules: false | ||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.11" |
There was a problem hiding this comment.
@kiranannadatha8 could you plz upgrade it to 3.12 cuz we switched the python to 312 and 313? We ran the CI but it failed for 3.11.
- pyproject: ruff config (line 99, py312, E/F/I), excludes for benchmarks/skyrl/scripts, per-file ignores for tests/examples - .pre-commit-config.yaml: ruff (--fix --select E,F,I) + ruff-format pinned to v0.4.4 — single source of truth for hook flags - dev extra: ruff>=0.4,<0.5, pre-commit>=3.6 - CI: new lint job runs `uv run pre-commit run --all-files` on py3.12 - CONTRIBUTING.md: pre-commit install + manual run instructions - one-shot ruff format + E,F,I fixes across clawloop/, tests/, examples/
3871ff9 to
6e1f3fd
Compare
|
@tianyibigdata bumped the lint job to Python 3.12 (was 3.11 — that was the CI fail). Also rebased onto latest Verified locally:
Single squashed commit, force-pushed with lease. |
- pyproject: ruff config (line 99, py312, E/F/I), excludes for benchmarks/skyrl/scripts, per-file ignores for tests/examples - .pre-commit-config.yaml: ruff (--fix --select E,F,I) + ruff-format pinned to v0.4.4 — single source of truth for hook flags - dev extra: ruff>=0.4,<0.5, pre-commit>=3.6 - CI: new lint job runs `uv run pre-commit run --all-files` on py3.12 - CONTRIBUTING.md: pre-commit install + manual run instructions - one-shot ruff format + E,F,I fixes across clawloop/, tests/, examples/
Summary
[tool.ruff]config to pyproject.toml (line-length 99, py311, select E/F/I, excludes benchmarks + skyrl submodule)ruff>=0.4,<0.5andpre-commit>=3.6in thedevextra.pre-commit-config.yamlwithruff+ruff-formathooks pinned tov0.4.4## Stylesection in CONTRIBUTING.md with pre-commit install instructionsruff format+--fixso the config change stays reviewable in isolationCloses #28.
Test plan
ruff check --select E,F,I clawloop tests examplesexits 0ruff format --check clawloop tests examplesexits 0EvalResult,field,Future,OptimResult)pip install -e ".[dev]" && pre-commit install— hooks run on commitOut of scope (deliberately, per issue)
UP/B/SIMrules — semantic rewrites, deferred