python – pep8警告大约8个空格缩进

这段代码:

def foo():
        print("hello")

违反了PEP 0008,其中指出

Use 4 spaces per indentation level.

但是pep8,pyflakes或flake8命令都没有警告它.

我怎样才能让其中一个人抱怨这个unpythonic代码?

最佳答案
pylint会警告这种违规行为:

$pylint test.py
No config file found, using default configuration
************* Module test
W:  2, 0: Bad indentation. Found 8 spaces, expected 4 (bad-indentation)

请注意,只有缩进is not a multiple of four(E111错误代码)时,pep8才会发出警告.

点赞