Getting Started

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 happens when you run it

  1. Seed mining — fetches closed, confirmed bug reports from mypy, pyrefly, and ty’s GitHub issues. Runs once, before generation starts.
  2. Code generation — those reports go to the LLM as seeds (or the built-in patterns, if there are no seeds), which writes new code targeting the same edge cases.
  3. Type checking — every generated example runs through mypy, pyrefly, zuban, and ty.
  4. Filtering — examples where the checkers disagree get kept. Examples where they all agreed get one more shot: the LLM gets the real checker output back and tries to provoke a disagreement, up to --max-refinements times.

Steps 2–4 repeat in batches until --num-examples disagreements are found, or --max-attempts is reached.

  1. Evaluation — every surviving disagreement gets executed under Phase 1 (runtime crash detection) and Phase 2 (Hypothesis fuzzing with type-conformant inputs) to figure out which checker was actually correct. Anything with no evidence either way gets escalated to an LLM judge. Full detail is on the Evaluation page.

Everything lands in generated_examples/<timestamp>/.

Install and run

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 installs mypy, pyrefly, zuban, and ty along with pytifex itself.

Picking a provider

OpenAI-compatible (real OpenAI, or any local/lab server)

# real OpenAI
export OPENAI_API_KEY=your_key
uv run --extra dev pytifex --model gpt-4o --openai-base-url https://api.openai.com/v1

# a local/lab server — no key needed unless the server itself requires one
uv run --extra dev pytifex --model qwen3-6b --openai-base-url http://localhost:8080/v1

Cohere

export COHERE_API_KEY=your_key
uv run --extra dev pytifex --model command-a-03-2025

If you omit both --model and --openai-base-url, the CLI falls back to Gemini internally — a leftover default, not a supported path. Always pass one of the two above.

Next steps