Skip to main content

image image image Documentation

unref

Find unreferenced Python code.

unref reports the unused functions, classes, methods, variables and attributes of a Python project: those that nothing references.

Documentation: unref.readthedocs.io

Quick start

Check the project in the current directory, using uvx:

$ uvx unref
src/project/models.py:12:7: unused-class 'Account'
src/project/utils.py:40:5: unused-function 'parse_date'

The tests, fixtures and hooks that pytest and unittest find by themselves count as used, without any configuration. See the configuration to change that, and for the other options.

Or run it as a pre-commit or prek hook, next to Ruff, which covers unused imports and local variables:

repos:
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.17.4
    hooks:
      - id: ruff-check
      - id: ruff-format
  - repo: https://github.com/Apakottur/unref
    rev: "" # The latest release.
    hooks:
      - id: unref

See the documentation for how the hook works.

Benchmark

Checking the whole CPython codebase (v3.14.0, about 2,100 files):

Tool Time
unref 2.66s
unref (one process) 9.87s
vulture 19.46s

Measured with scripts/benchmark.py.

Why

Unused code piles up in every codebase, and faster than ever now that AI tools write much of it and tend to leave unused code behind.

Finding and removing dead code reduces bloat, speeds up AI code scanning and simplifies development.

Ruff does not support this yet, see astral-sh/ruff#872. unref exists to fill the gap until Ruff supports it natively.

unref follows Vulture, the tool that has long filled this role, as a fast and modern package that follows the conventions of Ruff.

Contributing

See CONTRIBUTING.md.

Metadata

Release files for unref 0.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unref 0.0.9
File Size Uploaded Provenance Actions
unref-0.0.9.tar.gz 173.3 kB Without provenance Details for unref-0.0.9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for unref 0.0.9
File Interpreter ABI Platform Actions
unref-0.0.9-py3-none-any.whl Python 3 none any Details for unref-0.0.9-py3-none-any.whl

Total release size: 215.6 kB

Release files / unref-0.0.9.tar.gz

Download URL unref-0.0.9.tar.gz
Size 173.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e9fb9b1c1e5e57480a1c12a4328efc50f37992c821086a2716411e22b1bf07ff
BLAKE2b-256 checksum
How to use checksums
f1bf48934e31c96d4a4cc89824fecede8ea0b1182dfc50f6dc8c06cb144e8ce0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / unref-0.0.9-py3-none-any.whl

Download URL unref-0.0.9-py3-none-any.whl
Size 42.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
629e3d15cd80a250dbd895244a03952ac9f94656fcd3149fecc5b2f696e12ead
BLAKE2b-256 checksum
How to use checksums
08b886f36273e05b9dd39ede5b96472af19bd0a307260d0db5c598f0ffbc9c9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for unref 0.0.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page