--- id: deadcode version: "2.4.1" license: unclear license_treatment: agpl maintenance: active --- # deadcode — Find and remove dead code. License: agpl · Maintenance: active · Downloads: 218.5K/mo ## 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 above — 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 pip install deadcode uv add deadcode 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_current - Install friction: low - Maintenance: active - Downloads: 218.5K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags find unused code python, remove dead code automatically, unused variable detector, python code cleanup tool, detect unreachable code, unused import finder, static analysis dead code, static-analysis, code-cleanup, linting [View on SkillFed](https://skillfed.io/packages/deadcode) · [View on PyPI](https://pypi.org/project/deadcode/)