dead simple python dead code detection
Project description
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: v2.1.0
hooks:
- id: dead
how it works
- find all files in a repository using
git ls-filesand filtering:- only include files matched by the
--filesregex - exclude files matched by the
--excluderegex - only include files identified as
pythonbyidentify - classify test files by the
--testsregex
- only include files matched by the
- ast parse each file
- search for definitions and references
- 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dead-2.1.0.tar.gz.
File metadata
- Download URL: dead-2.1.0.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2b53c1ade71fc4aadafa74237b034b622d0bd3d81811d336d64e67083439d76
|
|
| MD5 |
c0283ff26beeecac514ae3d989623c09
|
|
| BLAKE2b-256 |
76694f7962497d9a6e63337803feba4c7da24cdd80fc361ba2ae0436a150ea9f
|
File details
Details for the file dead-2.1.0-py2.py3-none-any.whl.
File metadata
- Download URL: dead-2.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cde897c473a384673b4541f8d5bab4947d6240e1c195737467fe6c646585cd44
|
|
| MD5 |
fb30cd627c0464d1fa1f214c49d75bd4
|
|
| BLAKE2b-256 |
71a2a7b4945efa8df89f0a580b7a9dd2f06dd2ac45e6b55abbaf696577f432f9
|