Skip to main content

Build Status Azure DevOps coverage pre-commit.ci status

dead

dead simple python dead code detection

installation

pip install dead

cli

Consult the help for the latest usage:

$ dead --help
usage: dead [-h] [--files FILES] [--exclude EXCLUDE] [--tests TESTS]

optional arguments:
  -h, --help         show this help message and exit
  --files FILES      regex for file inclusion, default: ''
  --exclude EXCLUDE  regex for file exclusion, default '^$'
  --tests TESTS      regex to mark files as tests, default
                     '(^|/)(tests?|testing)/'

run the dead utility from the root of a git repository.

as a pre-commit hook

See pre-commit for instructions

Sample .pre-commit-config.yaml:

-   repo: https://github.com/asottile/dead
    rev: v1.4.0
    hooks:
    -   id: dead

how it works

  1. find all files in a repository using git ls-files and filtering:
    • only include files matched by the --files regex
    • exclude files matched by the --exclude regex
    • only include files identified as python by identify
    • classify test files by the --tests regex
  2. ast parse each file
    • search for definitions and references
  3. report things which do not have references

false positives

I wrote this in ~15 minutes on an airplane, it's far from perfect but often finds things. Here's a few things it's not good at:

  • functions which implement an interface are often marked as unused
  • metaclass magic is often marked as unused (enums, model classes, etc.)

suppressing dead

The # dead: disable comment will tell dead to ignore any line which has reportedly dead code.

is this project dead?

maybe.

Metadata

Release files for dead 1.4.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 dead 1.4.0
File Size Uploaded Provenance Actions
dead-1.4.0.tar.gz 6.5 kB Without provenance Details for dead-1.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dead 1.4.0
File Interpreter ABI Platform Actions
dead-1.4.0-py2.py3-none-any.whl Python 2, Python 3 none any Details for dead-1.4.0-py2.py3-none-any.whl

Total release size: 13.2 kB

Release files / dead-1.4.0.tar.gz

Download URL dead-1.4.0.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e02ec4ce22b030c594bd3aba2823bf5f95174c166ac974498d32936db36d22c7
BLAKE2b-256 checksum
How to use checksums
9dcfe499fa0a564f9bfcd17b25be7654d9dd5a4efc2f10ced66880b43a298f3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.5

Release files / dead-1.4.0-py2.py3-none-any.whl

Download URL dead-1.4.0-py2.py3-none-any.whl
Size 6.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
08fadc6cf50bca8acae70c3cd176cb7469a0ca0666860a72c2e944aff8775564
BLAKE2b-256 checksum
How to use checksums
33b893c7c6b0d8f13014d8548a6f81ba65b044052530cf91275b92f938df75bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.5

Security for dead 1.4.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