我有一个python项目,我想检查它是否符合PEP8。
我的setyp.cfg如下:
[pycodestyle]
count = True
ignore = E266, W504
max-line-length = 80
statistics = True
exclude = .venv,./build%经过一些清理之后,我的pycodestyle检查现在没有错误,也没有警告(当然,忽略了那些错误)
~/Workspace/my-app master ✔ 2h36m
➢ pycodestyle .
(.venv)
~/Workspace/my-app master ✔但是,对我的项目运行pylint会产生大量错误:
(中的一些只是为了演示而跟随)
************* Module somemodule.commands
src/somemodule/commands.py:98:0: C0330: Wrong continued indentation (add 16 spaces).
format(gcp_project)))
^ | (bad-continuation)
src/somemodule/commands.py:1:0: C0111: Missing module docstring (missing-docstring)
src/somemodule/commands.py:21:-1: W0105: String statement has no effect (pointless-string-statement)
src/somemodule/commands.py:29:4: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
src/somemodule/commands.py:45:4: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
src/somemodule/commands.py:41:16: W0613: Unused argument 'g_project' (unused-argument)
src/somemodule/commands.py:58:0: C0111: Missing function docstring (missing-docstring)
src/somemodule/commands.py:59:4: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
src/somemodule/commands.py:100:4: R1705: Unnecessary "else" after "return" (no-else-return)
src/somemodule/commands.py:102:8: C0103: Variable name "p2" doesn't conform to snake_case naming style (invalid-name)
src/somemodule/commands.py:123:4: C0103: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
src/somemodule/commands.py:139:0: C0111: Missing function docstring (missing-docstring)
src/somemodule/commands.py:2:0: C0411: standard import "import os" should be placed before "import click" (wrong-import-order)
src/somemodule/commands.py:3:0: C0411: standard import "import sys" should be placed before "import click" (wrong-import-order)
src/somemodule/commands.py:5:0: C0411: standard import "from subprocess import Popen, PIPE" should be placed before "import click" (wrong-import-order)这两个工具怎么会产生如此偏离的结果呢?
发布于 2020-03-26 13:10:16
我只是在这个问题上绊倒了,我亲自比较了一下pycodestyle和pylint。
简而言之,答案是pycodestyle是pylint的“子集”。让我引用基本python工具的一些话
https://stackoverflow.com/questions/57256056
复制相似问题