[![build status](https://github.com/asottile/dead/actions/workflows/main.yml/badge.svg)](https://github.com/asottile/dead/actions/workflows/main.yml)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/asottile/dead/main.svg)](https://results.pre-commit.ci/latest/github/asottile/dead/main)
dead
====
dead simple python dead code detection
## installation
```bash
pip install dead
```
## cli
Consult the help for the latest usage:
```console
$ 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](https://github.com/pre-commit/pre-commit) for instructions
Sample `.pre-commit-config.yaml`:
```yaml
- repo: https://github.com/asottile/dead
rev: v1.5.2
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`](https://github.com/chriskuehl/identify)
- classify test files by the `--tests` regex
1. ast parse each file
- search for definitions and references
1. 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._
Raw data
{
"_id": null,
"home_page": "https://github.com/asottile/dead",
"name": "dead",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "",
"author": "Anthony Sottile",
"author_email": "asottile@umich.edu",
"download_url": "https://files.pythonhosted.org/packages/1a/c3/be1b53fff92d02c8f51dc4c18a49f40f982e5736f3d835ba5e79caccfaad/dead-1.5.2.tar.gz",
"platform": null,
"description": "[![build status](https://github.com/asottile/dead/actions/workflows/main.yml/badge.svg)](https://github.com/asottile/dead/actions/workflows/main.yml)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/asottile/dead/main.svg)](https://results.pre-commit.ci/latest/github/asottile/dead/main)\n\ndead\n====\n\ndead simple python dead code detection\n\n## installation\n\n```bash\npip install dead\n```\n\n\n## cli\n\nConsult the help for the latest usage:\n\n```console\n$ dead --help\nusage: dead [-h] [--files FILES] [--exclude EXCLUDE] [--tests TESTS]\n\noptional arguments:\n -h, --help show this help message and exit\n --files FILES regex for file inclusion, default: ''\n --exclude EXCLUDE regex for file exclusion, default '^$'\n --tests TESTS regex to mark files as tests, default\n '(^|/)(tests?|testing)/'\n```\n\nrun the `dead` utility from the root of a git repository.\n\n## as a pre-commit hook\n\nSee [pre-commit](https://github.com/pre-commit/pre-commit) for instructions\n\nSample `.pre-commit-config.yaml`:\n\n```yaml\n- repo: https://github.com/asottile/dead\n rev: v1.5.2\n hooks:\n - id: dead\n```\n\n### how it works\n\n1. find all files in a repository using `git ls-files` and filtering:\n - only include files matched by the `--files` regex\n - exclude files matched by the `--exclude` regex\n - only include files identified as `python` by\n [`identify`](https://github.com/chriskuehl/identify)\n - classify test files by the `--tests` regex\n1. ast parse each file\n - search for definitions and references\n1. report things which do not have references\n\n### false positives\n\nI wrote this in ~15 minutes on an airplane, it's far from perfect but often\nfinds things. Here's a few things it's not good at:\n\n- functions which implement an interface are often marked as unused\n- metaclass magic is often marked as unused (enums, model classes, etc.)\n\n### suppressing `dead`\n\nThe `# dead: disable` comment will tell `dead` to ignore\nany line which has reportedly dead code.\n\n### is this project dead?\n\n_maybe._\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "dead simple python dead code detection",
"version": "1.5.2",
"project_urls": {
"Homepage": "https://github.com/asottile/dead"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "fe5f964ca37c7b04c32b72885bd00cabeb6dc6165e4218eabc24f3c8b89c5a27",
"md5": "eb995c660cf0ba358e3fcfafe6034e02",
"sha256": "4e97c2e4f4c4751b908b56831ab52a34d247570f6ef650c8a34b8b51950540bb"
},
"downloads": -1,
"filename": "dead-1.5.2-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "eb995c660cf0ba358e3fcfafe6034e02",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.8",
"size": 6603,
"upload_time": "2023-06-10T18:01:47",
"upload_time_iso_8601": "2023-06-10T18:01:47.725095Z",
"url": "https://files.pythonhosted.org/packages/fe/5f/964ca37c7b04c32b72885bd00cabeb6dc6165e4218eabc24f3c8b89c5a27/dead-1.5.2-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1ac3be1b53fff92d02c8f51dc4c18a49f40f982e5736f3d835ba5e79caccfaad",
"md5": "449076ffc0c4363aca99973ee067b631",
"sha256": "06d82da0adcac7821d45b147c019b3852644f9a23493c0b1578f1c8a7e4e73fd"
},
"downloads": -1,
"filename": "dead-1.5.2.tar.gz",
"has_sig": false,
"md5_digest": "449076ffc0c4363aca99973ee067b631",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 6321,
"upload_time": "2023-06-10T18:01:49",
"upload_time_iso_8601": "2023-06-10T18:01:49.143440Z",
"url": "https://files.pythonhosted.org/packages/1a/c3/be1b53fff92d02c8f51dc4c18a49f40f982e5736f3d835ba5e79caccfaad/dead-1.5.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-10 18:01:49",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "asottile",
"github_project": "dead",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "dead"
}