Add typing annotations to the code base to check internal API uses, also add running mypy to the pre-commit configuration to ensure we don't regress. The initial version will match the current implementation, later steps can tighten the type interfaces.