We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Deadcode - a tool to find and fix unused (dead) Python code — Albertas Gimbutas
Learn about Deadcode, a powerful Python tool that finds and removes unused code with precision. Discover features, configuration options and best practices for keeping codebases clean.
-
Deadcode is a new Python tool for finding and fixing unused code, offering more precise detection than existing tools like Vulture
-
Key features include:
- Automatic removal of unused code
- More comprehensive detection rules (13 types of checks)
- Configurable false positive filtering
- Dry run option to preview changes
- Support for namespace-aware detection
-
Dead code creates technical debt by:
- Consuming cognitive capacity
- Requiring maintenance during upgrades
- Potentially introducing security vulnerabilities through outdated dependencies
- Increasing codebase complexity
-
The tool works in three main steps:
- Finding all defined names
- Finding all usages
- Reporting/removing unused elements
-
Configuration options allow:
- Ignoring specific files or code sections
- Disabling specific checks
- Using decorators or inheritance to exclude code
- Writing no-quality-assurance comments inline
-
Handles special cases like:
- Django project meta definitions
- Data classes
- Type hints
- Empty file detection and removal
-
Future plans include:
- Possible integration into Ruff
- Development of a plugin system
- Standardization of detection procedures