# Pre-commit Hooks for Avlos

This project uses [pre-commit](https://pre-commit.com/) to automatically format and lint code before commits.

## Setup

1. Install pre-commit (if not already installed):
   ```bash
   pip install pre-commit
   ```

2. Install the git hooks:
   ```bash
   pre-commit install
   ```

## What Gets Checked

The pre-commit hooks run the following checks:

- **black**: Python code formatting (line length: 127)
- **isort**: Import statement sorting
- **flake8**: Python linting (configured in setup.cfg)
- **trailing-whitespace**: Removes trailing whitespace
- **end-of-file-fixer**: Ensures files end with a newline
- **check-yaml**: Validates YAML syntax
- **check-added-large-files**: Prevents large files from being committed
- **check-merge-conflict**: Detects merge conflict markers
- **mixed-line-ending**: Ensures consistent line endings
- **rstcheck**: Validates RST documentation files

## Manual Execution

To run all hooks on all files (useful after initial setup or major changes):
```bash
pre-commit run --all-files
```

To run hooks on specific files:
```bash
pre-commit run --files path/to/file1.py path/to/file2.py
```

To skip hooks for a single commit (not recommended):
```bash
git commit --no-verify
```

## Configuration

- Pre-commit hooks are configured in `.pre-commit-config.yaml`
- Flake8 and isort settings are in `setup.cfg`
- clang-format style is configured in `.clang-format`

## CI Integration

The same linting checks run in GitHub Actions CI, so passing pre-commit locally ensures CI will pass.
