PyLint bad-whitespace Configuration

拥有回忆 提交于 2020-12-30 08:35:38

问题


Is there a way to configure the checks for the bad-whitespace checks in PyLint? I can currently disable checking but I would much rather enforce a whitespace convention instead of disabling it.


回答1:


There are two options you could use:

  1. Globally disable the bad-whitespace warning:

    pylint --disable=C0326
    
  2. Use a Pylint configuration file:

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

    This is what you would put in the config file to disable the bad-whitespace warning:

    disable=C0326
    



回答2:


The .pylintrc file does offer limited editing of whitespace rules, using the attribute 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=

Might be more options in the near-future, though.




回答3:


The ID of bad-whitespace convention check is C0326 from pylint 1.1.0 onwards. You can use this code in the .pylintrc config file to enable/disable the bad-whitespace check.

[MESSAGES CONTROL]
enable=C0326

or

[MESSAGES CONTROL]
disable=C0326


来源:https://stackoverflow.com/questions/42198054/pylint-bad-whitespace-configuration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!