47

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"
latsha
  • 1,298
  • 1
  • 14
  • 22

10 Answers10

84

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

{
    "python.linting.pycodestyleEnabled": true,
    "python.linting.pycodestyleArgs": [
        "--ignore=E501" 
    ]
}

Before October 2019 all pycodestyle settings were named pep8:

{
    "python.linting.pep8Enabled": true,
    "python.linting.pep8Args": [
        "--ignore=E501" 
    ]
}
Phrogz
  • 296,393
  • 112
  • 651
  • 745
Juan Rada
  • 3,513
  • 1
  • 26
  • 26
  • How do I do multiple ignores? I tried a second `--ignore` line and I tried "E501,E266" but neither works – El Dude Nov 22 '17 at 21:35
  • 10
    @ElDude I'm probably too late, but this should work: `"python.linting.pep8Args": ["--ignore=E501", "--ignore=E301"]` – Markus Meskanen Dec 11 '17 at 23:51
  • 12
    Also (for anyone ending up here) `--ignore=E301,E501,E266` works as well. – uranusjr Mar 09 '18 at 05:36
  • Is it possible to ignore a warning for just one function? pylint allows it putting comments like `# pylint: disable=no-self-argument`. Is there something similar if I want to ignore `D403` for just one docstring of a function? – TrilceAC May 15 '20 at 17:25
30

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

Jamil Noyda
  • 3,321
  • 2
  • 21
  • 26
mangatinanda
  • 714
  • 10
  • 13
17

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
DaleS
  • 216
  • 3
  • 6
  • It worked for me, but is there any workarounds to make it for all projects at a time instead of creating setup.cfg for every projects? – latsha Nov 28 '16 at 04:03
  • The [documentation for pep8](http://pep8.readthedocs.io/en/release-1.7.x/intro.html#configuration) indicates that it is possible to create a user-level configuration file, but I have to admit that I haven't tried this. – DaleS Nov 30 '16 at 23:29
  • 1
    This works for me: ```"python.linting.pep8Args": [ "--ignore=E501" ],``` – Alex F May 26 '19 at 21:26
8

this worked for me:

"python.linting.flake8Enabled": true,
"python.linting.flake8Args": ["--ignore=E501"]
shimron
  • 596
  • 6
  • 19
5

To ignore multiple pycodestyle warnings:

{
    "python.linting.pycodestyleEnabled": true,
    "python.linting.pycodestyleArgs": [
        "--ignore=E501,W503" 
    ]
}
Magicoder
  • 330
  • 3
  • 13
4

Please try double quote " instead of single '

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

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

Martlark
  • 14,208
  • 13
  • 83
  • 99
Jamie Cha
  • 79
  • 1
2

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"]
}
Jared Shao
  • 21
  • 1
1

In case you are not using flake8Args but Pylama (for example) the configuration change on settings.json is similar as described before: "python.linting.pylamaArgs": ["--max_line_length=120"] or "python.linting.pylamaArgs": [""--ignore=E501" "]

CarlosJ
  • 63
  • 3
  • 8
1

What worked for me was adding the code snippet below to my user settings.json file. This was mentioned above but without the settings.json.

"python.linting.flake8Enabled": true,
"python.linting.flake8Args": ["--ignore=E501"]
Kqzz
  • 11
  • 2
  • 1
0

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

demongolem
  • 9,474
  • 36
  • 90
  • 105
wei
  • 111
  • 1
  • 9