39

I recently switched to Visual Studio Code and I have to say I love it so far.

I'm working on a Python project, which includes the pip packages pylint and autopep8 and I configured VSCode to format the code according to these packages.

Only problem is: In the Python project I'm working on the line length is 100. So all my code looks like this:

The error says: `E501:line too long (97 > 79 characters)

The error says: E501:line too long (97 > 79 characters). Here are my VSCode settings:

{
  "python.pythonPath": "~/.envs/myProject/bin/python",
  "python.linting.pep8Enabled": true,
  "python.linting.pylintPath": "~/.envs/myProject/bin/pylint",
  "python.linting.pylintArgs": ["--load-plugins", "pylint_django", "--max-line-length=100"],
  "python.formatting.autopep8Args": ["--max-line-length=100"],
  "python.linting.pylintEnabled": true,
  "files.exclude": {
    "**/.git": true,
    "**/.svn": true,
    "**/.hg": true,
    "**/CVS": true,
    "**/.DS_Store": true,
    ".vscode": true,
    "**/*.pyc": true
  }
}

These settings at least now ensure that format on save keeps the lines at 100 max and does not wrap all my files lines to 79. Still it would be awesome without the warnings.

How do I disable these linter warnings?

J. Hesters
  • 13,117
  • 31
  • 133
  • 249
  • confirmed, it doesn't work for me either. I also created a .pylintrc with the `max-line-length=120` but still get all these annoying errors – dcsan Jun 18 '20 at 20:29

6 Answers6

34

I figured out how to do this. Add this line to your settings:

"python.linting.pep8Args": ["--max-line-length=100"],
J. Hesters
  • 13,117
  • 31
  • 133
  • 249
  • 2
    `"python.linting.pep8Enabled": true` and `"python.formatting.pep8Args": ["--max-line-length=100"]` don't seem to be valid settings anymore. Your initial config should be enough – dtasev Nov 07 '19 at 13:52
  • 18
    At the time of writing, this works for me: `"python.linting.pylintArgs": ["--max-line-length=200"]` – Thomas Mundal Feb 19 '20 at 06:46
  • This setting will be soon depraciated. I followed answer from @Usman Tariq https://stackoverflow.com/a/75825695/10133085 `"pylint.args": ["--max-line-length=120"]` – Adam Kuzański Aug 21 '23 at 11:31
21

As of 2021 (Pylint reference), add this to your .vscode/settings.json file:

"python.linting.pylintArgs": ["--max-line-length=100"]
CodeBiker
  • 2,985
  • 2
  • 33
  • 36
15

For pycodestyle in Vscode 1.15.1:

"python.linting.pycodestyleArgs": ["--max-line-length=100"],
Janos
  • 796
  • 1
  • 9
  • 26
5

2020 version:

Add the following entry to your settings.json file

"python.linting.pylintArgs": ["-d", "C0301"],

If you haven't disabled these errors, and encounter a line too long warning, under "Problems" in VSCode, or by hovering over the underlined error, you will see VSCode say something along the lines of:

Line too long (188/100)Pylint(C0301:line-too-long)

As you can see, the value C0301 comes directly from this warning message. You can additionally disable other warnings by their error code as well.

Kraigolas
  • 5,121
  • 3
  • 12
  • 37
sobutterysosmooth
  • 775
  • 1
  • 8
  • 11
4

For me the following worked. (VSCode version == 1.73.0)

Go to Settings.

Search "pylint".

Scroll down to "Pylint : Args"

Click "Add Item"

Type this in, --max-line-length=200

Adjust the max-line-length to your desired length.

Community
  • 1
  • 1
amc007
  • 129
  • 7
2

For some reason, this setting worked for me:

"pylint.args": ["--max-line-length=100"]
Usman Tariq
  • 159
  • 1
  • 8