This project uses pre-commit hooks to enforce code quality standards before commits.
Install Python venv package (one-time setup):
sudo apt install python3-venvRun the automated setup script:
./setup-linters.shThis will:
- Create a virtual environment (
.venv-linters) - Install all development dependencies
- Set up pre-commit hooks
- Optionally run an initial check on all files
If you prefer manual setup:
# Create virtual environment
python3 -m venv .venv-linters
# Activate virtual environment
source .venv-linters/bin/activate
# Install dependencies
pip install -r requirements-dev.txt
# Install pre-commit hooks
pre-commit install
# Run initial check (optional)
pre-commit run --all-files- ruff: Linting and formatting (replaces black, isort, flake8)
- mypy: Static type checking
- shellcheck: Shell script analysis
- yamllint: YAML linting and formatting
- Trailing whitespace
- End of file fixes
- JSON syntax validation
- Large file detection
- Merge conflict detection
Hooks run automatically on git commit. If any check fails:
- Auto-fixable issues are corrected automatically
- Review the changes with
git diff - Stage the fixes with
git add - Commit again
Run checks manually without committing:
# Check all files
source .venv-linters/bin/activate
pre-commit run --all-files
# Check specific files
pre-commit run --files collector/src/api/app.py
# Check only staged files
pre-commit runIn rare cases where you need to bypass hooks:
git commit --no-verify.pre-commit-config.yaml- Pre-commit hooks configurationpyproject.toml- Python linting rules (ruff, mypy).yamllint.yaml- YAML linting rules.shellcheckrc- Shellcheck configurationrequirements-dev.txt- Development dependencies
The following are excluded from linting:
grafana/- Generated Grafana dashboards.git/,.venv*/- System directories__pycache__/,*.egg-info/- Build artifacts