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: v0.0.7
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.
Release files for dead 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dead-0.0.7.tar.gz | 5.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dead-0.0.7-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 11.3 kB
Release files / dead-0.0.7.tar.gz
| Download URL | dead-0.0.7.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2b1057c9a20d6425076f2aa0fe7371588513ec01acfb2fe6ddf70ca9d2f4c443
|
|
BLAKE2b-256 checksum How to use checksums |
c5863394732340f0699a83658136f3f688390f33a137750969e9fda02e155475
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.7
|
Release files / dead-0.0.7-py2.py3-none-any.whl
| Download URL | dead-0.0.7-py2.py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
6151b27bfc7aaaae0b4a6927bfcfa03bec66cc3d4416cb83d9d4903ed3f152b2
|
|
BLAKE2b-256 checksum How to use checksums |
a1018cd371fdcb0926c0d9017287ac2d2223fc648c32ed8cfb2548a7d293b11a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.7
|