mypy 是一个用于 Python 的静态类型检查器(type checker)。它根据代码中的类型注解(type hints)在不运行程序的情况下发现潜在的类型错误;也常用于提升代码可读性与大型项目的可维护性。(在不同语境中也可泛指“用 mypy 做类型检查”。)
I use mypy to catch type errors before running tests.
我用 mypy 在运行测试前先捕捉类型错误。
After adding type hints across the codebase, the team integrated mypy into CI to prevent new type-related bugs from being merged.
在整个代码库添加了类型注解之后,团队把 mypy 集成到持续集成(CI)中,以防止新的类型相关缺陷被合并进主分支。
/ˈmaɪpi/
mypy 的名字通常被理解为来自 “My” + “Py(thon)”:其中 “Py” 指 Python;整体暗示“为我的 Python 做类型检查”。它作为开源工具名在 Python 社区中广泛使用。