Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio code with PyLint and autoPep8: How can I avoid PyLint to complain about my line length?

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?

like image 514
J. Hesters Avatar asked Aug 28 '18 13:08

J. Hesters


People also ask

How do I run a Pylint code in Visual Studio?

To perform linting, open the Command Palette (Ctrl+Shift+P), filter on "linting", and select Python: Run Linting. Linting will run automatically when you save a file.

What does linter Pylint do?

Pylint is a static code analysis tool for the Python programming language. It is named following a common convention in Python of a "py" prefix, and a nod to the C programming lint program.


4 Answers

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

"python.linting.pep8Args": ["--max-line-length=100"],
like image 89
J. Hesters Avatar answered Oct 16 '22 13:10

J. Hesters


For pycodestyle in Vscode 1.15.1:

"python.linting.pycodestyleArgs": ["--max-line-length=100"],
like image 41
Janos Avatar answered Oct 16 '22 12:10

Janos


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

"python.linting.pylintArgs": ["--max-line-length=100"]
like image 11
CodeBiker Avatar answered Oct 16 '22 14:10

CodeBiker


2020 version:

Add the following entry to your settings.json file

"python.linting.pylintArgs": ["-d", "C0301"],
like image 4
sobutterysosmooth Avatar answered Oct 16 '22 12:10

sobutterysosmooth