Skip to content

Latest commit

 

History

History
62 lines (44 loc) · 1.15 KB

File metadata and controls

62 lines (44 loc) · 1.15 KB

Pre-commit Hooks Setup

Installation

# Install pre-commit
pip install pre-commit

# Install the git hooks
pre-commit install

# (Optional) Run against all files to verify
pre-commit run --all-files

What Gets Checked

  • black: Code formatting (88 char line length)
  • isort: Import statement sorting
  • flake8: Linting and style checking
  • mypy: Type checking (on src/madengine only)
  • bandit: Security vulnerability scanning
  • General checks: trailing whitespace, YAML/JSON validity, large files, merge conflicts

Usage

Pre-commit will now run automatically on git commit. If any hook fails:

  1. Review the output
  2. Fix the issues (many are auto-fixed)
  3. Stage the changes: git add <files>
  4. Commit again: git commit

Skipping Hooks (Not Recommended)

# Skip all hooks (emergency only)
git commit --no-verify

# Skip specific hooks
SKIP=mypy git commit

Manual Run

# Run on staged files
pre-commit run

# Run on all files
pre-commit run --all-files

# Run specific hook
pre-commit run black --all-files

Updating Hooks

# Update to latest versions
pre-commit autoupdate