In this lesson, you’ll explore how to use Mypy to do type checking on your Python code. Mypy is the most common tool for doing type checking:
Mypy is an optional static type checker for Python that aims to combine the benefits of dynamic (or “duck”) typing and static typing. (Source)
Mypy was started by Jukka Lehtosalo during his Ph.D. studies at Cambridge around 2012. Initially, Mypy started as a standalone variant of Python with seamless dynamic and static typing. See Jukka’s slides from PyCon Finland 2012 for examples of the original vision of Mypy.
Following a suggestion by Guido van Rossum, Mypy was rewritten to use annotations instead, making it a static type checker for regular Python code.
If you don’t have Mypy on your system, you can install it using pip:
charliem22 on Oct. 30, 2019
Hi Chris – I use PyCharm Professional and I’m wondering if there is any advantage to adding the Mypy plugin to my PyCharm environment. I searched a bit online and couldn’t find an obvious ‘value-added’ advantage. What’s your opinion/experience?
Thanks in advance, charlie