Skip to content

Introduce static type checking

Problems to solve

One common problem in dynamic language like Python is run-time type mismatch. This occurs when the actual type of a value does not match the expected type, leading to errors and bugs in the program. These type mismatches often go unnoticed until the program is executed, causing issues that are difficult to debug and fix (example).

Proposal

To avoid run-time type mismatch, it is recommended to use a static type checking tool such as mypy. Static type checking allows developers to catch type errors before the code is even executed, reducing the likelihood of encountering type-related bugs. By introducing mypy into the development process, developers can annotate their code with type hints and use mypy to check for any type inconsistencies. Since we are already using types extensively in the code base, this additional checking is a sensible next step and will help to improve the overall code quality.

References