Skip to content

Add custom git pre-commit hook for ruff#3

Closed
johnnymo87 wants to merge 2 commits intomainfrom
add-ruff-git-hooks
Closed

Add custom git pre-commit hook for ruff#3
johnnymo87 wants to merge 2 commits intomainfrom
add-ruff-git-hooks

Conversation

@johnnymo87
Copy link
Owner

Summary

  • Added a custom git pre-commit hook that runs ruff code quality checks
  • Created setup-git-hooks.sh script for easy installation
  • Updated documentation with setup instructions
  • Configured ruff to handle type-checking import rules appropriately

What this adds

  • setup-git-hooks.sh: Installation script for the git hook
  • Pre-commit hook: Runs ruff check and ruff format --check automatically
  • README updates: Clear instructions for optional git hook setup
  • Ruff config: Added TC002 to ignore list for type-checking imports

How it works

  1. Run ./setup-git-hooks.sh to install the hook
  2. Hook automatically runs on every git commit
  3. Checks only main package directories (excludes test/demo files)
  4. Provides clear error messages and fix suggestions
  5. Can be bypassed with git commit --no-verify when needed

Benefits

  • Fast feedback: Catch issues before they reach CI/CD
  • 🔧 Simple: No additional tool dependencies beyond uv + ruff
  • 🎯 Focused: Only checks main package code, not test files
  • 💡 Helpful: Clear error messages with fix suggestions
  • 🚀 Optional: Easy to install/skip as needed

Test plan

  • Hook installation script works correctly
  • Hook runs ruff checks on commit
  • Hook provides clear error messages for failures
  • Hook can be bypassed with --no-verify
  • Documentation is clear and complete

🤖 Generated with Claude Code

johnnymo87 and others added 2 commits June 19, 2025 19:15
- Replaced pre-commit hooks with ruff for linting, formatting, and import sorting
- Removed dependencies: flake8, pre-commit, flake8-type-checking, black, isort
- Added ruff configuration in pyproject.toml with comprehensive linting rules
- Updated CI workflow to run ruff check, ruff format, and mypy separately
- Updated README with new ruff-based code quality instructions
- Applied automatic code fixes and formatting via ruff
- Kept mypy as separate type checker for comprehensive type validation

Benefits:
- Faster execution (ruff is written in Rust)
- Unified tooling instead of multiple separate tools
- Better integration with uv ecosystem
- More comprehensive linting rules out of the box

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Created setup-git-hooks.sh script to install a custom git pre-commit hook
- Hook runs ruff check and ruff format --check on main package directories
- Updated README with git hook setup instructions
- Added TC002 to ruff ignore list (type-checking import rules need careful handling)
- Provides clear error messages and auto-fix suggestions
- Can be bypassed with --no-verify when needed

Benefits:
- Automatic code quality checks before each commit
- Fast feedback loop for developers
- No additional tool dependencies (uses existing uv + ruff)
- Cleaner than pre-commit framework for this simple use case

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@johnnymo87 johnnymo87 force-pushed the add-ruff-git-hooks branch from d29ddd9 to cb18f92 Compare June 19, 2025 23:16
@johnnymo87
Copy link
Owner Author

Added to #2

@johnnymo87 johnnymo87 closed this Jun 19, 2025
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.

1 participant