Skip to main content

image image image image

unref

Find dead code in Python projects: the unused functions, classes, methods, variables and attributes that nothing references.

Documentation: unref.readthedocs.io

Why

Unused code piles up in every codebase, faster than ever now that AI tools write much of it.

Ruff does not find unused code yet, see astral-sh/ruff#872. unref fills that gap until it does:

  • Just works: built-in rules for pytest, unittest, Pydantic, SQLAlchemy and FastAPI, so most projects need little or no configuration.
  • Ruff-style: same conventions, options and output style, and it covers what Ruff leaves out.
  • Fast: written in Rust on Ruff's parser, it checks all of CPython in under a second.
  • Modern: ty-style rule codes and configuration in pyproject.toml.

Quick start

Run it with uvx:

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

Or as a pre-commit or prek hook, alongside Ruff:

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: v0.1.0 # Or run `pre-commit autoupdate`.
    hooks:
      - id: unref

How it works

  • Matched by module: a function, class or variable is used only when its own module reads it, or another module reaches it through an import, module.name or __all__.
  • Installed base classes: base classes from the project's environment are followed, so the methods a subclass overrides count as used.
  • Ignore comments by code: # unref: ignore[...] names the rule it ignores, and a comment that ignores nothing is reported.

Benchmark

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

Tool Time
unref 0.94s
unref (one thread) 1.59s
vulture 19.68s

Measured with scripts/benchmark.py.

Contributing

False positives and other bugs are welcome as issues. To contribute code, see CONTRIBUTING.md.

Metadata

Release files for unref 0.2.0

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.2.0
File Size Uploaded Provenance Actions
unref-0.2.0.tar.gz 170.0 kB Without provenance Details for unref-0.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for unref 0.2.0
File Actions
unref-0.2.0-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details for unref-0.2.0-py3-none-win_arm64.whl
unref-0.2.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for unref-0.2.0-py3-none-win_amd64.whl
unref-0.2.0-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details for unref-0.2.0-py3-none-musllinux_1_2_x86_64.whl
unref-0.2.0-py3-none-musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64 Details for unref-0.2.0-py3-none-musllinux_1_2_aarch64.whl
unref-0.2.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details for unref-0.2.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
unref-0.2.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details for unref-0.2.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
unref-0.2.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for unref-0.2.0-py3-none-macosx_11_0_arm64.whl
unref-0.2.0-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details for unref-0.2.0-py3-none-macosx_10_12_x86_64.whl

Total release size: 19.4 MB

Release files / unref-0.2.0.tar.gz

Download URL unref-0.2.0.tar.gz
Size 170.0 kB
Tags Source
SHA-256 checksum
How to use checksums
49605acbc1e23725bb0a67a411d062e9458e86862cfd27f15767812f99d8f51b
BLAKE2b-256 checksum
How to use checksums
0b2059a8668711becf08a3323194bac321e28be0d71b12b4f3bcb3abc4adef6d
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.2.0-py3-none-win_arm64.whl

Download URL unref-0.2.0-py3-none-win_arm64.whl
Size 2.3 MB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
6cf63c42fc1122053f3f6251d4eead0d448b9935716e33ed4f89e40e854adfed
BLAKE2b-256 checksum
How to use checksums
10268bdc4ca990b938c3c72ae53250c78e8026e31e2c41f3927d9470b86abf89
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.2.0-py3-none-win_amd64.whl

Download URL unref-0.2.0-py3-none-win_amd64.whl
Size 2.5 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
1961c054c2599bd3939e44ee2478cef53951fc7748c0d2e3163f168342774700
BLAKE2b-256 checksum
How to use checksums
6790be77b0ac0ab666e8d0a571dc178bc0ac23860b85155eb21aa9e65ce1098a
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.2.0-py3-none-musllinux_1_2_x86_64.whl

Download URL unref-0.2.0-py3-none-musllinux_1_2_x86_64.whl
Size 2.5 MB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
fafe4cd52f4467593739e15e335589760b98ab74d5490382102f67f96523a0ca
BLAKE2b-256 checksum
How to use checksums
f29360bc471c60862943f0c9131e14022578445b8a25c9b30630d257f5efb390
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.2.0-py3-none-musllinux_1_2_aarch64.whl

Download URL unref-0.2.0-py3-none-musllinux_1_2_aarch64.whl
Size 2.4 MB
Tags Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
0e5c1bf26c4ab52ab8ede8d04eb60fe332146df9bb484b6d5fbf74692cf9fabe
BLAKE2b-256 checksum
How to use checksums
48ac40bd25482b30861a4bbe6f8d23f67d47898ebdba70eb9b52536e4bf045a9
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.2.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL unref-0.2.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 2.5 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
97850b6eec8d430fb9e747cb6188f94c719f4a92d8e8a9c54a0fb6bbebc545f2
BLAKE2b-256 checksum
How to use checksums
1a23f5b3a17c4893b5fe60ad268c9a9fcc70be1f0bd7c097a72e37e8753b9319
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.2.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL unref-0.2.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 2.3 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
91b251fae0f88999537be9fd8b3a42812d97f6e03ba6d29c108f1834f5e91408
BLAKE2b-256 checksum
How to use checksums
42d2a43e404d0857054442f0c8212c2c4405f243451c5bea911f373c5aec5158
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.2.0-py3-none-macosx_11_0_arm64.whl

Download URL unref-0.2.0-py3-none-macosx_11_0_arm64.whl
Size 2.3 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a0fd74e51d9111ad5a0abd42818dc23ec42d7dc3a9dc7a09ab186e4ea8c510b9
BLAKE2b-256 checksum
How to use checksums
bbc5bac9cb70d95f517b6e77b4a12f3b97b9e54a9da457b917e0c9dba7a9724a
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.2.0-py3-none-macosx_10_12_x86_64.whl

Download URL unref-0.2.0-py3-none-macosx_10_12_x86_64.whl
Size 2.4 MB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
27e060969747de036c18864e26c5c52177eb2396fa291761c6f015b8d378e72a
BLAKE2b-256 checksum
How to use checksums
6b25cc55c94d58c4cc82693ae6e62a89974787ec97e95ec95dc41a22341bb57c
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.2.0

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