Add this repo to your .pre-commit-config.yaml:
repos:
- repo: https://github.com/andrewaylett/pre-commit-hooks
rev: v0.7.1
hooks:
- id: cog
- id: init-hooksrepos:
- repo: https://github.com/andrewaylett/pre-commit-hooks
rev: v0.7.1
hooks:
- id: cogRuns cog against your README.md, README,
or if a file named .cogfiles exists, all files listed in that file.
The equivalent local incantation would be:
cog -r -c -p "import subprocess as sp, re, os, sys, pathlib as pl, cog" README.mdrepos:
- repo: https://github.com/andrewaylett/pre-commit-hooks
rev: v0.7.1
hooks:
- id: uv-run
name: Run pytest
args:
- pytest
- --verboseExecutes a project command using uv run.
This is roughly equivalent to this local hook:
- repo: local
hooks:
- id: uv-run
name: Run pytest
language: python
entry: uv run pytest --verbose
additional_dependencies:
- "uv==0.9.24"
pass_filenames: false
always_run: trueThe biggest difference is that pre-commit will cache the dedicated hook, while the local hook needs pre-commit
to download and use virtualenv and uv every time it's run.
repos:
- repo: https://github.com/andrewaylett/pre-commit-hooks
rev: v0.7.1
hooks:
- id: init-hooksEnsures that a baseline set of pre-commit hooks are enabled in the repository, along with their support files.
- .pre-commit-config.yaml
- trailing-whitespace
- end-of-file-fixer
- check-case-conflict
- check-merge-conflict
- check-yaml
- check-toml
- check-xml
- check-added-large-files
- forbid-submodules
- mixed-line-ending
- yamlfmt
- editorconfig-checker
- init-hooks
- If
.github/workflowsdirectory exists:- actionlint
- check-github-workflows
- If
renovate.jsonfile exists:- check-renovate
- .editorconfig
- Basic settings
- .yamlfmt.yaml
- Basic settings
- .gitignore
- Basic settings
If the files don't exist, they'll be created with sensible defaults. If the files already exist, but are missing entries, the missing entries will be added.
I highly recommend using uv to manage your python environment for this tool.
You don't need to use uv directly if you only want to use the hooks from pre-commit,
and if you really want to develop the tool without touching uv then you can run all the tests and lints using just pre-commit.
This project uses pytest for testing, ruff for linting and formatting, and pytype for typing. To run them all using poe:
uv run poe checkor using pre-commit:
uv run pre-commit run -aor if you prefer:
pre-commit run -a