【问题标题】:PyLint bad-whitespace ConfigurationPyLint 坏空白配置
【发布时间】:2017-02-13 06:43:26
【问题描述】:

有没有办法在 PyLint 中为 bad-whitespace 检查配置检查?我目前可以禁用检查,但我更愿意强制执行空白约定而不是禁用它。

【问题讨论】:

    标签: python pylint pylintrc


    【解决方案1】:

    您可以使用两个选项:

    1. 全局禁用 bad-whitespace 警告:

      pylint --disable=C0326
      
    2. 使用 Pylint 配置文件:

      pylint --rcfile=/path/to/config.file
      

      这是您将在配置文件中放入的内容以禁用错误空白警告:

      disable=C0326
      

    【讨论】:

      【解决方案2】:

      .pylintrc 文件确实提供了有限的空白规则编辑,使用属性no-space-check

      # List of optional constructs for which whitespace checking is disabled. `dict-
      # separator` is used to allow tabulation in dicts, etc.: {1  : 1,\n222: 2}.
      # `trailing-comma` allows a space between comma and closing bracket: (a, ).
      # `empty-line` allows space-only lines.
      no-space-check=
      

      不过,在不久的将来可能会有更多选择。

      【讨论】:

      【解决方案3】:

      bad-whitespace 约定检查的 ID 从 pylint 1.1.0 开始为 C0326。您可以在 .pylintrc 配置文件中使用此代码来启用/禁用bad-whitespace 检查。

      [MESSAGES CONTROL]
      enable=C0326
      

      [MESSAGES CONTROL]
      disable=C0326
      

      【讨论】:

        猜你喜欢
        • 2015-05-03
        • 2012-12-27
        • 2022-08-22
        • 1970-01-01
        • 1970-01-01
        • 2022-12-28
        • 1970-01-01
        • 2018-10-03
        • 1970-01-01
        相关资源
        最近更新 更多