diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bf7d8778cb..96b388971f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,19 +3,19 @@ repos: hooks: - id: ruff name: ruff - entry: bash -c 'source .venv/bin/activate && uv run ruff check --config pyproject.toml "$@"' -- + entry: uv run ruff check --config pyproject.toml language: system pass_filenames: true types: [python] - id: ruff-format name: ruff-format - entry: bash -c 'source .venv/bin/activate && uv run ruff format --config pyproject.toml "$@"' -- + entry: uv run ruff format --config pyproject.toml language: system pass_filenames: true types: [python] - id: mypy name: mypy - entry: bash -c 'source .venv/bin/activate && uv run mypy --config-file pyproject.toml "$@"' -- + entry: uv run mypy --config-file pyproject.toml language: system pass_filenames: true types: [python] @@ -30,7 +30,7 @@ repos: name: pip-audit # Keep this ignore list in sync with .github/workflows/vulnerability-scan.yml. entry: >- - bash -c 'source .venv/bin/activate && uv run pip-audit --skip-editable + uv run pip-audit --skip-editable --ignore-vuln PYSEC-2024-277 --ignore-vuln PYSEC-2026-89 --ignore-vuln PYSEC-2026-97 @@ -57,7 +57,7 @@ repos: --ignore-vuln PYSEC-2025-216 --ignore-vuln PYSEC-2025-217 --ignore-vuln PYSEC-2025-218 - --ignore-vuln GHSA-f4j7-r4q5-qw2c' -- + --ignore-vuln GHSA-f4j7-r4q5-qw2c language: system pass_filenames: false stages: [pre-push, manual] diff --git a/lib/crewai/tests/test_pre_commit_config.py b/lib/crewai/tests/test_pre_commit_config.py new file mode 100644 index 0000000000..2b86e2e647 --- /dev/null +++ b/lib/crewai/tests/test_pre_commit_config.py @@ -0,0 +1,25 @@ +"""Tests for the repository's local pre-commit hooks.""" + +from pathlib import Path + +import yaml + + +def test_local_hooks_use_uv_without_shell_activation() -> None: + """Local hooks should work on Windows as well as Unix-like systems.""" + root = Path(__file__).resolve().parents[3] + config = yaml.safe_load( + (root / ".pre-commit-config.yaml").read_text(encoding="utf-8") + ) + + local_hooks = [ + hook + for repository in config["repos"] + if repository["repo"] == "local" + for hook in repository["hooks"] + if "entry" in hook + ] + + 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)