A pre-commit and prek hook for unref, an extremely fast Python dead code finder.
It is a separate repository so that the hook installs the prebuilt wheel of unref from PyPI, rather than building unref from source.
Add the hook to your .pre-commit-config.yaml:
repos:
- repo: https://github.com/Apakottur/unref-pre-commit
rev: v0.5.1
hooks:
- id: unrefprek reads .pre-commit-config.yaml too, but it also supports its own prek.toml format:
[[repos]]
repo = "https://github.com/Apakottur/unref-pre-commit"
rev = "v0.5.1"
hooks = [{ id = "unref" }]The hook checks the whole project rather than the changed files, as finding unused code needs every file. To configure unref, see its documentation.