Typed Python with MyPy

The “The DAO” hack1 threw me down a “how safely can I write code” rabbit hole2, which has led to me picking up typed Python forĀ my current project3.

Support for “type hints” was introduced in PEP 484 and implemented for the first time in Python 3.5. As Python is not and will not at any time in the future be a proper statically typed language, the PEP describes a method of “hinting” at types using structured comments and other syntactic sugar which the Python 3.5 compiler studiously ignores. External utilities can then interpret and enforce as they will. While in theory this allows for competition among approaches, at present there’s only one functional type checker: MyPy.