skillfed

deadcode

Find and remove dead code.

deadcode v2.4.1 218.5K downloads/30d#9,340 on PyPI172
AGPL license Active released

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 deadcode

uv

uv add deadcode

poetry

poetry add deadcode

Installing 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

Development Status :: 3 - AlphaLicense :: OSI Approved :: GNU Affero General Public License v3Natural Language :: EnglishOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12

Tags

find unused code pythonremove dead code automaticallyunused variable detectorpython code cleanup tooldetect unreachable codeunused import finderstatic analysis dead code
static-analysiscode-cleanuplinting

More Quality Assurance packages