mypy
noun
say it: “MY-py” /ˈmaɪˌpaɪ/
A tool that reads Python code and its type hints without running it, and reports places where a value doesn't match its hint, such as text passed where a number is expected.
What is mypy?
mypy is a tool that reads your type hints and warns you about type mistakes before you run the code.
# shop.py
def total(price: float, qty: int) -> float:
return price * qty
total("9.99", 2)
# mypy shop.py
# error: Argument 1 to "total" has incompatible type "str"; expected "float"
In a sentence
- “The team runs mypy before every commit, next to the tests.”
- “mypy caught that total("9.99", 2) passed a string where a float was expected.”
Level: Freelancer · More Python terms at this level
Updated