【问题标题】:pep8 warn about 8-space indentpep8 警告 8 空格缩进
【发布时间】:2016-07-11 02:18:52
【问题描述】:

这段代码:

def foo():
        print("hello")

违反PEP 0008,其中规定

每个缩进级别使用 4 个空格。

pep8pyflakesflake8 命令都没有对此发出警告。

我怎样才能让他们中的一个抱怨这个 unpythonic 代码?

【问题讨论】:

    标签: python pylint pep8 pyflakes flake8


    【解决方案1】:

    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)
    

    请注意,pep8 只会在缩进 is not a multiple of four(E111 错误代码)时向您发出警告。

    【讨论】:

      猜你喜欢
      • 2016-03-18
      • 2017-04-11
      • 1970-01-01
      • 1970-01-01
      • 2021-09-29
      • 2018-11-14
      • 2015-10-22
      • 2019-12-12
      • 2015-11-25
      相关资源
      最近更新 更多