Scan a large Python project to find functions, classes, and imports that are never called anywhere.
Run Vulture as a pre-commit hook so dead code is flagged automatically before every git commit.
Generate a whitelist file for code Vulture incorrectly flags as unused so future scans stay noise-free.
Use the --min-confidence flag to focus cleanup work on only the highest-confidence unused code findings.
Vulture is a command-line tool for Python developers that scans a codebase and reports code that is never used: unused functions, classes, variables, imports, and unreachable blocks. In a large project that has grown over time, it is common to accumulate old code that nothing calls anymore, and Vulture is designed to surface those leftovers so they can be removed. The tool works through static analysis, meaning it reads the source files without running the program. Because Python is a dynamic language, this approach has limits: code that gets called indirectly (through reflection or dynamic dispatch) may be flagged incorrectly. To handle this, Vulture assigns a confidence percentage to each finding, from 60 percent for things like attributes and class variables up to 100 percent for function arguments and provably unreachable code. Developers can use the --min-confidence flag to focus only on the highest-confidence results. For false positives (code that Vulture flags but actually is used), the recommended approach is to create a whitelist file that lists those items. Vulture can generate this whitelist automatically with the --make-whitelist option. Files or directories can also be excluded entirely, and specific function names or decorator patterns can be ignored with additional flags. Configuration can be stored in a pyproject.toml file under the [tool.vulture] section, which avoids having to repeat flags on every run. Vulture also integrates with pre-commit, so it can run automatically before each git commit to catch dead code early. Installation is via pip. Running it is as simple as pointing Vulture at a Python file or directory. After removing flagged code, running it a second time is recommended, since removing one piece of dead code can reveal others that depended on it.
← jendrikseipp on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.