Visual studio code suppress pep8 warnings

2019-03-17 12:22发布

How can I suppress pep8 warnings, in Visual studio code? What I want to do is to suppress E501 warning I don't want to get warnings where my code length is more than 80 chars. I'm using Don Jayamanne's Python extension and here is my config file for vscode

{
    "python.linting.pylintEnabled": false,
    "python.linting.pep8Enabled": true,
    "python.pythonPath": "/workspace/virtualenvs/abr/bin/python3",
    "python.linting.enabled": true
}

I know that there is one another option "python.linting.pep8Args": [] but I couldn't to get it work. I've installed pep8 on virtualenv

What I've already tried.

  1. "python.linting.pep8Args": ['--ignore=E501']
  2. "Searched all visual studio code settings"

7条回答
兄弟一词,经得起流年.
2楼-- · 2019-03-17 12:43

Please try double qoute " instead of single '

['--ignore=E501'] --> ["--ignore=E501"]

It worked for me. Don't forget to restart the program.

查看更多
欢心
3楼-- · 2019-03-17 12:45

Either use setup.cfg for single project or change your user settings for all py files.

{
    "python.linting.pep8Enabled": true,
     "python.linting.pep8Args": [
         "--ignore=E501" 
     ]
}
查看更多
男人必须洒脱
4楼-- · 2019-03-17 12:50

If you want to change the line length, add this in your User Settings file

{ 
  "python.linting.pep8Enabled": true,
  "python.linting.pep8Args": ["--max-line-length=120" ]
}

previous code was giving me 'EOF' error, so i edited it

查看更多
Juvenile、少年°
5楼-- · 2019-03-17 12:51

I found the answer at https://code.visualstudio.com/docs/python/linting for vscode 1.31.1

solved it via modify settings.json

{
    "workbench.iconTheme": "material-icon-theme",
    "workbench.colorTheme": "Material Theme Ocean",
    "git.autofetch": true,
    "python.linting.flake8Args": ["--ignore=E501", "--verbose"]
}

查看更多
趁早两清
6楼-- · 2019-03-17 13:01

I was fighting with this a couple of weeks ago. What I ended up doing was adding a setup.cfg file into the root folder of my project and putting the following in it:

[pep8]
ignore = E501
查看更多
闹够了就滚
7楼-- · 2019-03-17 13:03

What you did is correct. However you have to start the VScode to see the difference. (I would prefer vs auto update itself.)

查看更多
登录 后发表回答