跳转到主要内容

静态检查您的Python代码

项目描述

py_static_check

py_static_check可以静态检查您的Python代码中的许多常见错误。它使用修改后的pyflakes代码,并扩展了以下功能

  • 可以指定星号导入解析到什么 (-s 参数)

  • 可以忽略未使用导入的警告 (-i 参数)

  • 更好的警告/错误排序

更多信息请查看

要安装它,请执行以下操作

sudo easy_install py_static_check

以下是py_static_check可以执行的一些操作。

捕获未定义的名称,即使是星号导入

示例代码

from os import *

def function_with_error():
    print path
    print paths

star_imports.py

import os
STAR_IMPORTS = {
    'os': os.__all__,
}

当使用py_static_check运行时

$ py_static_check -s tests/star_import.py tests/undefined_name_star.py
tests/undefined_name.py:5: undefined name 'paths

忽略未使用警告

示例代码

from os import path

当使用py_static_check -i 选项运行时

$ py_static_check -i tests/ignore_not_used.py

$ py_static_check tests/ignore_not_used.py
tests/ignore_not_used.py:10: 'path' imported but unused

已分配但未使用

与pyflakes一样,它可以捕获许多错误,例如定义未使用的变量。

示例代码

def some_function():
    def inner_fn():
        local_var = ""

当使用py_static_check运行时

$ py_static_check tests/assigned_but_never_used.py

tests/assigned_but_never_used.py:8: local variable 'local_var' is assigned to but never used

版权:2011年 amix 版权:MIT。

项目详情


下载文件

下载适合您平台文件的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源分布

py_static_check-1.2.tar.gz (10.5 kB 查看哈希值)

上传时间: 源码

构建版本

py_static_check-1.2-py2.7.egg (22.0 kB 查看哈希值)

上传时间: 源码

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面