Skip to content

fix: make pre-commit hooks portable on Windows - #6881

Open
Vaishnavi220506 wants to merge 1 commit into
crewAIInc:mainfrom
Vaishnavi220506:codex/fix-windows-precommit
Open

fix: make pre-commit hooks portable on Windows#6881
Vaishnavi220506 wants to merge 1 commit into
crewAIInc:mainfrom
Vaishnavi220506:codex/fix-windows-precommit

Conversation

@Vaishnavi220506

Copy link
Copy Markdown

Summary

Fixes #6863.

The local pre-commit hooks sourced .venv/bin/activate through Bash, which fails on Windows before Ruff, Ruff Format, mypy, or pip-audit can run. The hooks now invoke uv run directly, allowing uv to select the project environment on every supported platform.

A regression test verifies that every local hook uses uv run and does not depend on the Unix-only activation path.

Validation

  • pytest lib/crewai/tests/test_pre_commit_config.py -q -n 0 — passed
  • pre-commit run --files lib/crewai/tests/test_pre_commit_config.py — Ruff and Ruff Format passed
  • pre-commit validate-config — passed

The repository-wide all-files run still reports unrelated existing Ruff/mypy issues outside this change.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

No new commits to review since the last review.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2f0abcc6-98c9-4173-be15-8d90a4d19162

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Local pre-commit hooks now call Ruff, Ruff Format, Mypy, and pip-audit through direct uv run commands. A pytest verifies that local hook entries use this format and omit .venv/bin/activate.

Changes

Pre-commit hook execution

Layer / File(s) Summary
Direct uv run hook commands
.pre-commit-config.yaml
Ruff, Ruff Format, Mypy, and pip-audit no longer use shell-based virtual-environment activation or argument forwarding.
Hook command validation
lib/crewai/tests/test_pre_commit_config.py
The test loads local hooks and verifies that each entry starts with uv run and does not reference .venv/bin/activate.

Suggested reviewers: greysonlalonde

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes replace Unix-only activation with uv run and add regression coverage, meeting issue #6863 requirements.
Out of Scope Changes check ✅ Passed The configuration change and regression tests are limited to the Windows portability objective in issue #6863.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly identifies the main change: making pre-commit hooks portable on Windows.
Description check ✅ Passed The description directly explains the Windows portability fix, the implementation, regression test, and validation results.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Vaishnavi220506
Vaishnavi220506 marked this pull request as ready for review August 9, 2026 07:45

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
lib/crewai/tests/test_pre_commit_config.py (1)

23-25: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert the intended tool for each hook.

The current assertions only check the uv run prefix. An entry could invoke the wrong tool for its hook ID and still pass. Assert command prefixes for ruff, ruff-format, mypy, and pip-audit by 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

📥 Commits

Reviewing files that changed from the base of the PR and between f7ba8e3 and 78c8fff.

📒 Files selected for processing (2)
  • .pre-commit-config.yaml
  • lib/crewai/tests/test_pre_commit_config.py

@Vaishnavi220506

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

[BUG] pre-commit hooks fail on Windows due to hardcoded Unix virtual environment path

1 participant