Show HN: Unref – A Python dead code finder built on Ruff's parser
Unref is a fast Rust-based Python dead code finder built on Ruff's parser, capable of checking large codebases in under a second.
summary is enough It is a promising new developer tool with impressive performance, though early versions require refinement for popular web frameworks.
summary
Unref is a new dead code analyzer for Python written in Rust that leverages Ruff's parser to outperform tools like Vulture by up to 20x. It defines dead code as anything unreachable from application entry points or a library's public API. Early user feedback highlights significant speed and usability, alongside false positives with framework-specific patterns in Django and Flask that the author is actively patching. It integrates easily via uvx, pre-commit hooks, and GitHub Actions.
key points
- Unref analyzes the entire CPython codebase in under a second, outperforming existing alternatives like Vulture.
- It distinguishes between applications and libraries, targeting code unreachable from entry points or public APIs.
- Early adopters report high false-positive rates with frameworks like Django and Flask, prompting immediate updates from the author.
who should read it
Python developers looking for fast static analysis tools to integrate into their CI/CD and pre-commit workflows.
discussion positive
consensus
Commenters praise the tool's extreme speed and immediate utility, while providing constructive bug reports regarding false positives in frameworks.
Cool project. I think false positives are more important than the dead code it misses at this stage. For example, it marks all Django settings as unused variables, probably because settings are typically not imported directly in Django projects. For example:
from django.conf import settings ... if settings.DEBUG: ...
Currently unref thinks that DEBUG is not used.
Similarly, the `application` variable in asgi.py (or wsgi.py) is passed as an argument to the ASGI/WSGI server executable, but that is also marked as unused.
Pointed out specific false-positive scenarios in Django that prompted the author to immediately commit fixes for framework support.
Generated by an LLM from the article and thread. Check the sources before relying on it.