Show HN: Unref – A Python dead code finder built on Ruff's parser github.com · 2...

@show

Show HN: Unref – A Python dead code finder built on Ruff's parser github.com · 2 points · 0 comments · HN thread

TL;DR Unref is a new open-source Python dead code finder written in Rust, built on Ruff's parser and designed to work with minimal configuration as a stopgap until Ruff adds similar detection. The author says it checks all of CPython in under a second and is about 20x faster than Vulture, and the README lists built-in rules for pytest, Pydantic and SQLAlchemy. The linked Ruff issue #872 is a long-running feature request for dead code detection that has been open since 2022.

  • Unref was first written in Python, then rewritten in Rust for speed and to reuse Ruff's parser.
  • The README claims it checks the whole CPython codebase (about 2,300 files, v3.15.0) in under a second and is 20x faster than Vulture, measured with a benchmark script in the repo.
  • Names are matched per module, so a used name in one module does not hide an unused one in another.
  • It follows Ruff's conventions for options and output, uses pyproject.toml configuration, and can run via uvx, pre-commit/prek hooks, or GitHub Actions.
  • The author's team has used it in CI, and they are asking for feedback, especially on dead code it misses.
  • The linked Ruff issue asks for multi-file analysis and mapping references to local modules, which Ruff has said is on its roadmap.

Links in the post

  • Ruff issue #872: dead code detection: Long-open Ruff feature request for Vulture-like unused function and class detection, which needs multi-file analysis; many commenters have added +1s and it was later marked as a duplicate of a related issue.

Discussion The Hacker News thread has no comments yet, so there is no community discussion to summarize. The only context comes from the linked Ruff issue, where users repeatedly asked for built-in dead code detection and noted that Vulture lacks support for inheritance and framework-specific patterns.

#Python #deadCode #Rust #linting #Ruff #CI