Check out MyPy for Improving Your Python Project
-
Fedora Magazine this month talks about the mypy utility. MyPy is a static type checker for Python.
According to MyPy:
Migrate existing code to static typing, a function at a time. You can freely mix static and dynamic typing within a program, within a module or within an expression. No need to give up dynamic typing — use static typing when it makes sense. Often just adding function signatures gives you statically typed code. Mypy can infer the types of other variables.
Python syntaxMypy type checks programs that have type annotations conforming to PEP 484. Getting started is easy if you know Python. The aim is to support almost all Python language constructs in mypy.
Powerful type systemMypy has a powerful, modern type system with features such as bidirectional type inference, generics, callable types, abstract base classes, multiple inheritance and tuple types.
Access to Python libsMany commonly used libraries have stubs (statically typed interface definitions) that allow mypy to check that your code uses the libraries correctly.