Pre-commit Hooks¶
AirSense ML uses pre-commit hooks to enforce code quality and conventional commit messages on every commit automatically.
Hooks Configured¶
| Hook | Purpose |
|---|---|
ruff |
Lint Python files, auto-fix where possible |
ruff-format |
Format Python files |
conventional-pre-commit |
Enforce conventional commit message format |
Installation¶
1. Install dev dependencies¶
2. Install pre-commit hooks¶
3. Install commit-msg hook (conventional commits)¶
Usage¶
Hooks run automatically on every git commit. No manual steps needed.
To run hooks manually against all files:
To update hook versions:
Conventional Commit Format¶
All commit messages must follow this format:
Allowed types:
| Type | When to use |
|---|---|
feat |
New feature |
fix |
Bug fix |
chore |
Maintenance, dependency updates |
docs |
Documentation changes |
refactor |
Code restructuring, no behaviour change |
perf |
Performance improvement |
test |
Adding or updating tests |
build |
Build system, Docker, Makefile changes |
Examples:
feat: add batch prediction endpoint
fix: resolve circular import in core.__init__
chore: update ruff to v0.15.6
docs: update development log phases
refactor: split feature_engineering into separate modules
build: optimise Docker image — strip nvidia packages
Rejected examples:
Configuration¶
Hooks are defined in .pre-commit-config.yaml at project root:
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.6
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v3.4.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
args: [feat, fix, chore, docs, refactor, perf, test, build]
Skipping Hooks¶
For generated files like changelogs — skip pre-commit with --no-verify:
Use sparingly. Never skip on feature commits.