python代码质量检查工具_pyre-check: Pyre 是一个快速、可扩展和高性能的 Python 类型检查工具,适用于大型的 Python 3 代码库,旨在通过在终端或编辑器中以交互方式标记...

Pyre is a performant type checker for Python compliant with PEP 484. Pyre can analyze codebases with millions of lines of code incrementally – providing instantaneous feedback to developers as they write code.

Pyre ships with Pysa, a security focused static analysis tool we've built on top of Pyre that reasons about data flows in Python applications. Please refer to our documentation to get started with our security analysis.

Requirements

To get started, you need Python 3.6 or later and watchman working on your system. On MacOS you can get everything with homebrew:

$brew installpython3 watchman

On Ubuntu, Mint, or Debian; use apt-get:

$sudoapt-get installpython3 python3-pip watchman

We tested Pyre on Ubuntu 16.04 LTS, CentOS 7, as well as OSX 10.11 and later.

Setting up a Project

We start by creating an empty project directory and setting up a virtual environment:

$mkdirmy_project && cdmy_project

$python3 -m venv ~/.venvs/venv

$source ~/.venvs/venv/bin/activate

(venv) $pip installpyre-check

Next, we teach Pyre about our new project:

(venv) $pyre init

This command will set up a configuration for Pyre (.pyre_configuration) as well as watchman (.watchmanconfig) in your project's directory. Accept the defaults for now – you can change them later if necessary.

Running Pyre

We are now ready to run Pyre:

(venv) $echo "i: int = 'string'" > test.py

(venv) $pyre

ƛ Found 1 typeerror!

test.py:1:0 Incompatible variable type [9]: i is declared to have type `int` but is used as type `str`.

This first invocation will start a daemon listening for filesystem changes – type checking your project incrementally as you make edits to the code. You will notice that subsequent invocations of pyre will be faster than the first one.

For more detailed documentation, see https://pyre-check.org.

Join the Pyre community

See CONTRIBUTING.md for how to help out.

License

Pyre is licensed under the MIT license.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值