unref¶
An extremely fast Python dead code finder, written in Rust.
Documentation: unref.readthedocs.io
Source Code: github.com/Apakottur/unref
Introduction¶
unref finds the functions, classes, methods, variables and attributes that nothing in a Python project
uses. Unused code piles up in every codebase, faster than ever now that AI tools write much of it, and
Ruff does not find it yet, see
astral-sh/ruff#872. The name is short for "unreferenced".
- 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.
Example¶
$ uvx unref
src/project/models.py:12:7: unused-class 'Account'
src/project/utils.py:40:5: unused-function 'parse_date'
See usage for the command line, pre-commit and prek, and GitHub Actions.