Vulture scans Python files or trees for unused imports, functions, variables, and unreachable blocks, assigning confidence scores so teams can prune dead code safely.
Overview
Vulture performs static analysis on Python source to list unused definitions and unreachable statements. It helps maintain large codebases by highlighting imports, attributes, classes, functions, and variables that never appear used, with confidence percentages based on construct type.
The CLI accepts files or directories, honors .gitignore via --exclude patterns, and can sort findings by size to prioritize big dead blocks. Whitelists, pyproject.toml configuration, flake8 noqa compatibility, and pre-commit hooks support gradual cleanup workflows.
Because Python is dynamic, some false positives occur; maintainers recommend generated whitelist modules or explicit ignores for framework patterns such as Flask route decorators. Similar tools like pyflakes complement its focus on dead code rather than syntax errors.
Vulture ships on PyPI, integrates with GitHub Actions, offers a VS Code extension, and exposes a programmatic API for custom pipelines.
Key features
- Static unused code detection for Python
- Confidence scores per finding type
- Directory scanning with ignore files
- --sort-by-size dead code ranking
- Whitelist and pyproject.toml config
- Pre-commit and GitHub Action integrations
- Unreachable code after return or break
- Flake8 noqa F401 and F841 compatibility
Use cases
- Cleaning unused modules before refactors
- Finding untested functions via dual scans
- CI gates on new dead code
- Preparing libraries for release shrinkage