跳转到主要内容

Python风格指南检查器

项目描述

Build status Documentation Status Wheel Status Join the chat at https://gitter.im/PyCQA/pycodestyle

pycodestyle 是一个工具,用于检查您的 Python 代码是否符合PEP 8中的一些风格约定。

特性

  • 插件架构:添加新的检查非常容易。

  • 可解析的输出:在您的编辑器中跳转到错误位置。

  • 小巧:仅一个 Python 文件,仅需要标准库。您可以使用 pycodestyle.py 文件来完成此目的。

  • 附带全面的测试套件。

安装

您可以使用以下命令安装、升级和卸载 pycodestyle.py

$ pip install pycodestyle
$ pip install --upgrade pycodestyle
$ pip uninstall pycodestyle

还有一个适用于 Debian/Ubuntu 的软件包,但它并不总是最新的版本。

示例用法和输出

$ pycodestyle --first optparse.py
optparse.py:69:11: E401 multiple imports on one line
optparse.py:77:1: E302 expected 2 blank lines, found 1
optparse.py:88:5: E301 expected 1 blank line, found 0
optparse.py:347:31: E211 whitespace before '('
optparse.py:357:17: E201 whitespace after '{'
optparse.py:472:29: E221 multiple spaces before operator

您还可以让 pycodestyle.py 显示每个错误的源代码,甚至是来自 PEP 8 的相关文本。

$ pycodestyle --show-source --show-pep8 testing/data/E40.py
testing/data/E40.py:2:10: E401 multiple imports on one line
import os, sys
         ^
    Imports should usually be on separate lines.

    Okay: import os\nimport sys
    E401: import sys, os

或者您还可以显示每个错误被发现的多频繁。

$ pycodestyle --statistics -qq Python-2.5/Lib
232     E201 whitespace after '['
599     E202 whitespace before ')'
631     E203 whitespace before ','
842     E211 whitespace before '('
2531    E221 multiple spaces before operator
4473    E301 expected 1 blank line, found 0
4006    E302 expected 2 blank lines, found 1
165     E303 too many blank lines (4)
325     E401 multiple imports on one line
3615    E501 line too long (82 characters)

项目详情


下载文件

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

源代码分发

pycodestyle-2.12.1.tar.gz (39.2 kB 查看哈希值)

上传时间

构建分发

pycodestyle-2.12.1-py2.py3-none-any.whl (31.3 kB 查看哈希值)

上传时间 Python 2 Python 3

由以下机构支持

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