Overview

GitHub Python 3.12+ License: MIT

Pytifex finds cases where Python type checkers disagree with each other. It mines real bug reports from type checker repositories, uses them as seeds for an LLM to generate new code, runs that code through four checkers, and keeps only the examples where the checkers don’t agree. Then it figures out which checker was actually right, using runtime execution as the ground truth.

What uv run pytifex actually does, in order

1. Mine seeds — once, up front, unless --no-github. Pulls closed, confirmed bug-fix issues straight from GitHub:

# github_issues.py
def is_confirmed_bug(issue: dict) -> bool:
    if issue.get("state") != "closed":
        return False
    if issue.get("state_reason") == "not_planned":
        return False
    return True

2. Generate — a batch of new code gets written by the LLM, seeded from those issues (or from the built-in patterns if there are no seeds):

# pipeline.py
if seed_examples:
    prompt = build_seed_based_prompt(batch_seeds, batch_size)
else:
    prompt = build_expert_prompt(batch_size)

3. Check — every generated example runs through mypy, pyrefly, zuban, and ty.

4. Filter — a disagreement is any example where the checkers don’t all return the same status:

# pipeline.py
def has_disagreement(results: dict[str, CheckerResult]) -> bool:
    statuses = [r.status for r in results.values()]
    return len(set(statuses)) > 1

Disagreements get kept as-is. Examples where all four checkers agreed get one shot at a fix: sent back to the LLM with the real checker output attached, up to --max-refinements times. Steps 2–4 repeat in batches until --num-examples disagreements are found, or --max-attempts runs out.

5. Evaluate — everything that survived gets saved to generated_examples/<timestamp>/, then run through two phases: Phase 1 checks whether the code crashes at runtime, Phase 2 fuzzes it with Hypothesis-generated, type-conformant inputs. Whichever phase finds concrete proof decides which checker was right. If neither does, an LLM judge gets the final say.

A verdict is never guessed upfront — it only gets issued once there’s an actual crash or an actual successful run behind it.

Type checkers tested

Checker Version
mypy 1.19.0
pyrefly 0.44.2
zuban 0.3.0
ty 0.0.1-alpha.32

Quick start

git clone https://github.com/benedekaibas/pytifex
cd pytifex

export COHERE_API_KEY=your_key

uv run --extra dev pytifex --model command-a-03-2025

--extra dev is what pulls in mypy, pyrefly, zuban, and ty — they’re an optional dependency group in pyproject.toml, not a base dependency, so a plain uv run pytifex won’t install them.

Pytifex is a research tool I built for a senior comprehensive project. The idea is to find type checker bugs proactively, before a user runs into them in production.

Where to go next