Skip to content

pre-commit hooks

Some pre-commit hooks I use frequently.

Example .pre-commit-config.yaml file

.pre-commit-config.yaml
repos:

- repo: https://gitlab.com/vojko.pribudic/pre-commit-update
  rev: v0.1.1
  hooks:
    - id: pre-commit-update

- repo: https://github.com/kynan/nbstripout
  rev: 0.6.1
  hooks:
    - id: nbstripout

Auto-update pre-commit hooks

This hook will update the revisions for all installed hooks each time pre-commit runs.

.pre-commit-config.yaml
1
2
3
4
5
- repo: https://gitlab.com/vojko.pribudic/pre-commit-update
  rev: v0.1.1
  hooks:
    - id: pre-commit-update
      args: [--dry-run --exclude black --keep isort]

Automatically strip Jupyter notebooks on commit

This hook will scan for jupyter notebooks (.ipynb) and clear any cell output before committing.

.pre-commit-config.yaml
1
2
3
4
- repo: https://github.com/kynan/nbstripout
  rev: 0.6.1
  hooks:
    - id: nbstripout