简体   繁体   English

是否有根据类型提示检查类型的 python linter?

[英]Is there a python linter that checks types according to type hints?

I'm looking for a Python linter, that can check types usage according to the type hints in the code.我正在寻找一个 Python linter,它可以根据代码中的类型提示检查类型的使用情况。
The purpose is to run a single check that verifies style, logic, and type errors.目的是运行单一检查来验证样式、逻辑和类型错误。
I need to run this on CI server, and as a file watcher during development.我需要在 CI 服务器上运行它,并在开发过程中作为文件观察者。
For example, I need this code to output an error for passing the wrong type argument -例如,我需要这个代码到 output 传递错误类型参数的错误 -

def double(x: int):
    return x * 2


result = double('hello')

I've checked the documentation of PyLint and flake8, and couldn't find any support for type checking.我检查了 PyLint 和 flake8 的文档,找不到任何对类型检查的支持。
With PyLint I also verified there are no errors when checking the above code.使用 PyLint,我还验证了检查上述代码时没有错误。

Yes, there is, it's called mypy是的,有,它叫mypy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM