Mypy implementation translated to Python (for running mypy only)