Unref is a Python dead-code finder implemented in Rust and built on Ruff’s parser. It scans code for unreferenced definitions, reporting findings such as unused classes and functions with file locations. Its central design goal is to identify unused code quickly without treating identical names in different modules as interchangeable: references are matched by module, so a use of a name in one module does not conceal an unused definition elsewhere. The project also provides built-in handling for conventions used by pytest, Pydantic, SQLAlchemy, and other libraries, aiming to work on typical projects with little configuration.
The project reports that Unref checks the roughly 2,300 files in CPython 3.15.0 in under a second, and is 20 times faster than Vulture in its benchmark. It presents itself as a complement to Ruff: Unref follows Ruff-like conventions and output, while finding unused code Ruff does not cover. Rule codes follow a style likened to ty, and configuration lives in pyproject.toml. Developers can run it with uvx, add it as a pre-commit or prek hook alongside Ruff, or use it in GitHub Actions. The repository is MIT-licensed and invites bug reports, including reports of false positives.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.