Vulture

2.16 · active · verified Thu Apr 09

Vulture is a Python library and command-line tool designed to find dead code in Python programs. It analyzes your code for unused functions, classes, methods, and variables by building an abstract syntax tree (AST) and then performing reachability analysis. Currently at version 2.16, it maintains an active development cycle with several releases per year, incorporating new Python version support and bug fixes.

Warnings

Install

Imports

Quickstart

Initialize Vulture and scan a code string or files to find unused code. The `get_unused_code()` method returns an iterator of `Item` objects, each representing a piece of dead code.

from vulture import Vulture

code_string = """
def my_unused_function():
    return 42

def my_used_function():
    print('Hello')

my_used_function()
"""

v = Vulture()
v.scan(code_string)

print("Found dead code:")
for item in v.get_unused_code():
    print(f"- {item.typ}: {item.name} at {item.filename}:{item.lineno}")

view raw JSON →