Skip to main content

Automated mutation-based differential testing for Python type checkers

Project description

Pytifex

Python 3.12+ License: MIT

Automated mutation based differential testing for Python type checkers. Pytifex discovers disagreements between type checkers by mining historical bug reports, generating targeted test cases with an LLM, and establishing ground truth through runtime validation testing.

For more information, see the Pytifex documentation.

Note: Pytifex implements a bug-seeded mutation methodology for proactively finding type checker bugs before users encounter them.

Type Checkers

Pytifex tests the following type checkers:

Checker Version Repository
mypy 1.19.0 python/mypy
pyrefly 0.44.2 facebook/pyrefly
zuban 0.3.0 zubanls/zuban
ty 0.0.1-alpha.32 astral-sh/ty

Divergence Patterns

Pattern Description PEPs
protocol-defaults Protocol methods with different default argument values 544
typed-dict-total TypedDict with mixed total/Required/NotRequired inheritance 589, 655
typeguard-narrowing TypeGuard/TypeIs with generic type parameters 647, 742
param-spec-decorator ParamSpec decorators on classmethods/staticmethods 612
self-generic Self type in generic classes with abstract methods 673
newtype-containers NewType in containers (covariance/contravariance) 484
overload-literals Overloaded functions with Literal type discrimination 484, 586
final-override Final attributes overridden by properties 591
keyword-vs-positional Protocol callables with keyword-only parameters 544, 570
bounded-typevars TypeVar bounds with nested generics 484

Installation

Prerequisites: Python 3.12+, uv

To download and run Pytifex, please follow the following commands:

pip install pytifex

*or*

pip3 install pytifex

NOTE: Type checkers are automatically installed by uv when you run the tool.

Usage

# You have to set your Google Gemini API key in your terminal window
export GEMINI_API_KEY="your-api-key-here"

# Run the full pipeline: mine → generate → filter → evaluate
uv run pytifex

# Generate until N disagreements are found
uv run pytifex --num-examples 10

# Use a different model
uv run pytifex --model gemini-2.5-pro

# Skip GitHub seed fetching
uv run pytifex --no-github

Commands

Command Description
uv run pytifex Full pipeline (generate + evaluate)
uv run pytifex generate Generate disagreements only
uv run pytifex check Run type checkers on existing examples
uv run pytifex eval Evaluate existing results

Options

Option Default Description
--num-examples N 5 Target disagreement count
--batch-size N 15 Examples per LLM batch
--max-attempts N 5 Max generation attempts
--max-refinements N 2 Refinement attempts per example
--model MODEL gemini-2.5-flash Gemini model
--eval-method METHOD comprehensive Evaluation method
--no-github Skip GitHub seed fetching
-v, --verbose Show all examples

Evaluation

Pytifex uses a multi-phase evaluation oracle to determine which checker is correct:

Phase Method Confidence
0 AST-based PEP specification oracle 0.85–0.95
1 Runtime crash detection 0.95–1.0
2 Hypothesis property-based testing 0.85
3 PEP specification compliance matching 0.80
4 Static flow analysis 0.80

Key insight: Runtime behavior is the ultimate ground truth. If code raises TypeError at runtime, any checker that reported "OK" is definitively wrong.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytifex-0.1.5.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytifex-0.1.5-py3-none-any.whl (114.4 kB view details)

Uploaded Python 3

File details

Details for the file pytifex-0.1.5.tar.gz.

File metadata

  • Download URL: pytifex-0.1.5.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.13

File hashes

Hashes for pytifex-0.1.5.tar.gz
Algorithm Hash digest
SHA256 7e7c2dd8a2d6bc5c6a12773e8d776db42b1ae7fd95b1251e88cd6f1b9f8735cd
MD5 bca54bd4c7ccf15ef68ff9dea12accc8
BLAKE2b-256 621b535af9501fea70def14ce65216b596b5ae0256e3d6d2e10f8ceaaebe10d8

See more details on using hashes here.

File details

Details for the file pytifex-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: pytifex-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 114.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.13

File hashes

Hashes for pytifex-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7fb7dc1aadfcf3c1b0be97e43021ab296a0e29a485a2aaf424c69cf0932448a4
MD5 e94b9e46a24546c25a6b564b0941cb24
BLAKE2b-256 974d78513145ca58e8d55dcf41f1b52b7652b03d5ad49a84aadd11449787e9f1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page