Skip to content

Optimize pre-commit speed by setting always_run to false - #96

Merged
xingyaoww merged 1 commit into
mainfrom
openhands/optimize-precommit-speed
Sep 4, 2025
Merged

xingyaoww merged 1 commit into
mainfrom
openhands/optimize-precommit-speed

Conversation

@xingyaoww

Copy link
Copy Markdown
Contributor

Summary

This PR optimizes pre-commit speed by changing always_run from true to false for all hooks in .pre-commit-config.yaml. This allows hooks to run only on changed files locally, significantly improving development speed while maintaining complete CI coverage.

Changes Made

  • Changed always_run: true to always_run: false for all hooks (ruff-format, ruff-check, pycodestyle, pyright)
  • Changed pass_filenames: false to pass_filenames: true for ruff-format, ruff-check, and pyright hooks
  • This enables file-specific execution instead of always running on the entire codebase

Impact

Local Development:

  • Pre-commit hooks now only run on changed Python files
  • Significantly faster pre-commit execution for incremental changes
  • Hooks are skipped entirely when no relevant files are changed

CI Coverage:

  • No impact on CI coverage - .github/workflows/precommit.yml uses --all-files flag
  • All hooks still run on all files in CI, ensuring complete validation

Testing

  • ✅ Verified hooks skip when no Python files are changed
  • ✅ Verified hooks run correctly on specific Python files
  • ✅ Verified --all-files flag still works for complete coverage
  • ✅ Pre-commit hooks executed successfully during commit

Fixes #95

@xingyaoww can click here to continue refining the PR

- Changed always_run from true to false for all hooks
- Changed pass_filenames from false to true for ruff-format, ruff-check, and pyright
- This allows hooks to run only on changed files locally, improving speed
- CI workflow still uses --all-files flag to ensure complete coverage
- Fixes #95

Co-authored-by: openhands <openhands@all-hands.dev>
@xingyaoww
xingyaoww merged commit fde4406 into main Sep 4, 2025
@xingyaoww
xingyaoww deleted the openhands/optimize-precommit-speed branch September 4, 2025 12:38
@openhands-ai openhands-ai Bot mentioned this pull request Sep 4, 2025
StressTestor pushed a commit to StressTestor/software-agent-sdk that referenced this pull request Jun 1, 2026
Co-authored-by: openhands <openhands@all-hands.dev>
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.

Optimize pre-commit speed

2 participants