An extremely fast Python dead code finder, written in Rust.
Maintained. Last release 2 days ago, commits in 3 of the last 26 weeks. Weaker on commit activity and contributor spread.
$
pip install unrefREADME as published on PyPI with version 0.6.2.
unref
An extremely fast Python dead code finder, written in Rust.
Checking the whole CPython codebase (v3.15.0, about 2,300 Python files),
measured with scripts/benchmark.py.
- Fast: 20x faster than vulture, it checks all of CPython's Python code in under a second.
- Just works: built-in rules for pytest, Django, Flask, Pydantic, SQLAlchemy and more, so most projects need little or no configuration.
- Flexible: works for applications and libraries alike, see what counts as dead code.
- Modern: follows the conventions of Ruff and ty.
- Fits your workflow: runs with
uvx, as a pre-commit or prek hook, and in GitHub Actions.
Documentation: unref.readthedocs.io
Getting Started
Run it with uvx:
$ uvx unref
src/project/models.py:12:7: unused-class 'Account'
src/project/utils.py:40:5: unused-function 'parse_date'
Or as a pre-commit or prek hook, alongside Ruff:
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.17.5
hooks:
- id: ruff-check
- id: ruff-format
- repo: https://github.com/Apakottur/unref-pre-commit
rev: v0.6.2
hooks:
- id: unref
See the FAQ for adopting unref in an existing project.
Contributing
Bug reports and other feedback are welcome as issues. To contribute, see CONTRIBUTING.md.