Configuring PEP8 using VS Code

Configure VS Code

To automatically highlight code style errors in VS Code, we can use the already installed Python plugin.

  • Open your settings by clicking File -> Preferences -> Settings. Make sure that “User settings” is selected on the right.
  • Search for “pep8” and set it to enabled in your settings. It should look like: "python.linting.pep8Enabled": true
  • Unfortunately the module “pep8” is deprecated, we need to use pycodestlye instead. As a workaround we need to add this line: "python.linting.pep8Path": "pycodestyle"
  • Also VS Code enables Pylint (another linter like PEP8, that we don’t use), please turn it off by turning this line to false: "python.linting.pylintEnabled": false

Configure PEP8

Using only 79 columns in a Python script can be blocking and hard to use. We agreed on extending this limit to 120 characters, so we need to change the basic settings of PEP8. In VS Code you do this by adjusting autopep8Args and pep8Args settings.

After all this you user settings should have the following entries:

// Place your settings in this file to overwrite the default settings

{
  "python.pythonPath": "python3.5",
  "python.linting.pep8Enabled": true,
  "python.linting.pep8Path": "pycodestyle",
  "python.linting.pylintEnabled": false,
  "python.formatting.autopep8Args": ["--max-line-length=120"],
  "python.linting.pep8Args": ["--max-line-length=120"]
}

Make sure you save your settings after you changed them!