Home

Awesome

mypy_test

Test mypy plugins, stubs, custom types.

Create a Python file, add comments to lines where you expect mypy to produce an error, run mypy_test, and it will check if actual errors are the same as you expect.

Features:

python3 -m pip install mypy-test

Usage

  1. Write a file you want to test, add comments to the lines you expect to fail:

    a = 1
    reveal_type(a)  # R: builtins.int
    
  2. Run the tool:

    python3 -m mypy_test example.py
    

Writing the comments

Example:

var = 1.1
reveal_type(var)  # R: builtins.float

# E: Incompatible types in assignment (expression has type "str", variable has type "float")
var = ""

Tips:

Alternatives