type-check-without-type-error (TRY004) 源自 tryceratops linter。 作用 检查未引发 TypeError 的类型检查。 为什么这不好? Python 文档指出,遇到不合适的类型时应引发 TypeError。 示例 def foo(n: int): if isinstance(n, int): pass else: raise ValueError("n must be an integer") 建议改为 def foo(n: int): if isinstance(n, int): pass else: raise TypeError("n must be an integer") 参考 Python 文档:TypeError