fix: make pre-commit hooks portable on Windows - #6881
Conversation
|
Important Review skippedNo new commits to review since the last review. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughLocal pre-commit hooks now call Ruff, Ruff Format, Mypy, and pip-audit through direct ChangesPre-commit hook execution
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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.
🧹 Nitpick comments (1)
lib/crewai/tests/test_pre_commit_config.py (1)
23-25: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAssert the intended tool for each hook.
The current assertions only check the
uv runprefix. An entry could invoke the wrong tool for its hook ID and still pass. Assert command prefixes forruff,ruff-format,mypy, andpip-auditby hook ID.Proposed test strengthening
assert local_hooks assert all(hook["entry"].startswith("uv run ") for hook in local_hooks) assert all(".venv/bin/activate" not in hook["entry"] for hook in local_hooks) + expected_prefixes = { + "ruff": "uv run ruff check --config pyproject.toml", + "ruff-format": "uv run ruff format --config pyproject.toml", + "mypy": "uv run mypy --config-file pyproject.toml", + "pip-audit": "uv run pip-audit --skip-editable", + } + hooks_by_id = {hook["id"]: hook for hook in local_hooks} + assert set(expected_prefixes) <= set(hooks_by_id) + for hook_id, prefix in expected_prefixes.items(): + assert hooks_by_id[hook_id]["entry"].startswith(prefix)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lib/crewai/tests/test_pre_commit_config.py` around lines 23 - 25, Strengthen the assertions in the pre-commit hook test by mapping each hook ID to its expected command prefix and validating the corresponding hook["entry"] for ruff, ruff-format, mypy, and pip-audit. Retain the existing checks for local hooks, the uv run prefix, and absence of .venv/bin/activate.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@lib/crewai/tests/test_pre_commit_config.py`:
- Around line 23-25: Strengthen the assertions in the pre-commit hook test by
mapping each hook ID to its expected command prefix and validating the
corresponding hook["entry"] for ruff, ruff-format, mypy, and pip-audit. Retain
the existing checks for local hooks, the uv run prefix, and absence of
.venv/bin/activate.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2cfc5518-d11e-48cc-bd79-f4186b07be67
📒 Files selected for processing (2)
.pre-commit-config.yamllib/crewai/tests/test_pre_commit_config.py
|
@coderabbitai review |
|
Summary
Fixes #6863.
The local pre-commit hooks sourced
.venv/bin/activatethrough Bash, which fails on Windows before Ruff, Ruff Format, mypy, or pip-audit can run. The hooks now invokeuv rundirectly, allowinguvto select the project environment on every supported platform.A regression test verifies that every local hook uses
uv runand does not depend on the Unix-only activation path.Validation
pytest lib/crewai/tests/test_pre_commit_config.py -q -n 0— passedpre-commit run --files lib/crewai/tests/test_pre_commit_config.py— Ruff and Ruff Format passedpre-commit validate-config— passedThe repository-wide all-files run still reports unrelated existing Ruff/mypy issues outside this change.