CrossHair

0.0.102 · active · verified Thu Apr 16

CrossHair is an analysis tool for Python that utilizes symbolic execution to blur the line between traditional testing and type systems. It works by repeatedly calling functions with symbolic inputs and employing an SMT solver to explore execution paths, finding counterexamples to contracts defined within docstrings. The library currently stands at version 0.0.102 and has a fairly active release cadence with frequent minor updates.

Common errors

Warnings

Install

Imports

Quickstart

Install CrossHair and then run it from the command line to watch your code for contract violations. Define post-conditions and other contracts within function docstrings. CrossHair will continuously analyze the specified files and report any counterexamples.

# my_code.py
def divide(a: int, b: int) -> float:
    """
    post: __return__ == a / b
    """
    return a / b

# Run CrossHair from your terminal:
# crosshair watch my_code.py

view raw JSON →