Visual Studio代码抑制pep8警告

lat*_*sha 34 pep8 visual-studio-code

如何在Visual Studio代码中抑制pep8警告?我想要做的是抑制E501警告我不希望得到警告我的代码长度超过80个字符.我正在使用Don Jayamanne的Python扩展,这是我的vscode配置文件

{
    "python.linting.pylintEnabled": false,
    "python.linting.pep8Enabled": true,
    "python.pythonPath": "/workspace/virtualenvs/abr/bin/python3",
    "python.linting.enabled": true
}
Run Code Online (Sandbox Code Playgroud)

我知道还有另外一个选项"python.linting.pep8Args":[]但是我无法让它工作.我在virtualenv上安装了pep8

我已经尝试过的.

  1. "python.linting.pep8Args":[' - signore = E501']
  2. "搜索所有视觉工作室代码设置"

jcr*_*ada 65

将setup.cfg用于单个项目或更改所有py文件的用户设置.

{
    "python.linting.pycodestyleEnabled": true,
    "python.linting.pycodestyleArgs": [
        "--ignore=E501" 
    ]
}
Run Code Online (Sandbox Code Playgroud)

  • 另外(对于在这里结束的任何人)`--ignore = E301,E501,E266`也可以. (10认同)
  • @ElDude我可能为时已晚,但这应该有效:`"python.linting.pep8Args":[" - ignore = E501"," - ignore = E301"]` (9认同)

man*_*nda 23

如果要更改行长度,请在"用户设置"文件中添加

{ 
  "python.linting.pep8Enabled": true,
  "python.linting.pep8Args": ["--max-line-length=120" ]
}
Run Code Online (Sandbox Code Playgroud)

以前的代码给了我'EOF'错误,所以我编辑了它


小智 15

几个星期前,我正在与此作斗争.我最终做的是将一个setup.cfg文件添加到我的项目的根文件夹中并将以下内容放入其中:

[pep8]
ignore = E501
Run Code Online (Sandbox Code Playgroud)


shi*_*ron 6

这对我有用:

"python.linting.flake8Enabled": true,
"python.linting.flake8Args": ["--ignore=E501"]
Run Code Online (Sandbox Code Playgroud)


Mag*_*der 5

忽略多个 pycodestyle 警告:

{
    "python.linting.pycodestyleEnabled": true,
    "python.linting.pycodestyleArgs": [
        "--ignore=E501,W503" 
    ]
}
Run Code Online (Sandbox Code Playgroud)