deadcode
Find and remove dead code.
What it is and what it does
Deadcode is a static analysis tool that identifies unused code at the module level across a Python codebase. Unlike linters such as ruff or flake8 which only detect unused local variables, deadcode finds global-scope dead code: unused variables, functions, classes, methods, attributes, imports, properties, and empty files. It can also detect unreachable code blocks and commented-out code. The tool runs as a command-line scanner and optionally removes detected dead code automatically.
It integrates with pyproject.toml for configuration and supports fine-grained filtering through command-line options and inline noqa comments. You can exclude directories, ignore specific names or patterns, skip code in certain files, and ignore definitions that inherit from particular base classes or use specific decorators. The tool is designed to complement other static checkers rather than replace them.
Use it for:
- Clean up legacy codebases by identifying and removing unused functions, classes, and variables across the entire project
- Automate code hygiene in CI/CD pipelines by detecting dead code and optionally fixing it with --fix
- Reduce false positives from other linters by filtering out test base classes, mixins, and framework-specific patterns
- Find empty Python files and unreachable code blocks after refactoring
- Maintain code quality in large teams by catching accumulated dead code before it accumulates further
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Scans Python codebases to find and optionally remove unused variables, functions, classes, methods, attributes, imports, and other dead code expressions.
Yes, if you need global-scope dead code detection. The tool fills a gap that ruff and flake8 don't cover, has low install friction, active maintenance, and no known vulnerabilities. The AGPL v3 license is the main consideration: acceptable for open-source and internal tools, but requires careful evaluation in proprietary contexts. Start with --dry mode to evaluate false positives in your codebase.
Install
deadcode on PyPI
pip
pip install deadcodeuv
uv add deadcodepoetry
poetry add deadcodeInstalling deadcode
Before you install
Low friction install with a single runtime dependency (tomli). Actively maintained with recent commits; marked as Alpha status but in active development.
License in practice
Licensed under AGPL v3, which requires derivative works and modifications to be distributed under the same license. Use in proprietary projects requires careful review of your distribution model.
Quickstart
pip install deadcode
deadcode .
deadcode . --fix --dry
deadcode . --fix --only foo.py
Requires Python 3.10 or higher. Files with syntax errors are skipped; the tool uses ast parsing and assumes it runs on the same or higher Python version as the codebase being checked.
Verify before relying
- Whether the tool handles dynamic code patterns (e.g., getattr, __import__) or only static AST analysis
- Performance characteristics on large codebases (time, memory, CPU consumption)
- Accuracy of false-positive filtering with the various ignore options in real-world projects
Package facts
| License | not declared (agpl) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — tomli |
| Maintenance | actively maintained — 735 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 218,491/month — #9,340 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: deadcode-2.4.1-py3-none-any.whl
Tags
More Quality Assurance packages
Coverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
ruffRuff is a Python linter and code formatter…
permissive · top 1,000 on PyPI
pexpectPexpect spawns and controls interactive console…
permissive · top 1,000 on PyPI
blackBlack reformats Python source code to a…
permissive · top 1,000 on PyPI
pytest-xdistpytest-xdist distributes pytest tests across…
permissive · top 1,000 on PyPI
cfn-lintValidates AWS CloudFormation templates in YAML…
permissive · top 1,000 on PyPI
refurbRefurb is a static analysis tool that scans…
copyleft · top 15,000 on PyPI
uncalledDetects unused functions in Python projects…
permissive · top 15,000 on PyPI
vultureVulture is a static code analyzer that finds…
permissive · top 5,000 on PyPI
autoflakeautoflake removes unused imports and unused…
permissive · top 5,000 on PyPI
eradicateEradicate detects and removes commented-out…
permissive · top 5,000 on PyPI
yesqayesqa automatically removes unnecessary `#…
permissive · top 15,000 on PyPI
cppcleancppclean analyzes C++ source code to identify…
permissive · top 15,000 on PyPI
fawltydepsFawltydeps identifies undeclared dependencies…
permissive · top 15,000 on PyPI
pytest-unused-fixturesA pytest plugin that identifies and reports…
permissive · top 15,000 on PyPI
flake8-unused-argumentsA flake8 plugin that detects unused function…
permissive · top 15,000 on PyPI