Home > Software engineering >  VS Code pycodestyle not recognizing errors
VS Code pycodestyle not recognizing errors

Time:06-22

I'm using Atom as code editor on Ubuntu 20.04 and I currently try whether VS Code might be a replacement for my purposes. One thing that annoys me a lot with VS code is that linting doesn't work as expected - and as I was used to with Atom. The below will be specifically for pycodestyle.

One issue is that quite a lot of warnings are not reported at all, such as e225 or e303.

Another is that too long lines are ignored at all once I increase the 80 character limit to 120 by adding the args "--line-length" and "120".

How can I fix these issues?

CodePudding user response:

The functions you mentioned are the requirements of "flake8". You need to install falke8 and yapf first by the following code :

pip install flake8
pip install yapf

Then we configure linting in vscode and add the following contents to setting.json(ctrl shift P and choose "preferences:open settings(json)"):

"python.linting.flake8Enabled": true,
"python.formatting.provider": "yapf",
"python.linting.flake8Args": [
    "--max-line-length=120"
],
"python.linting.pylintEnabled": false

In this way, the format recognition of flake8 is started, and your second problem can also be effectively solved. I made a simple reproduction:

enter image description here

  • Related