3

I write in Visual Studio Code 1.29.1 some code in Python 3 and I'd like to have it check to be ok with Pep8. So I have selected pep8 liter option and it works but is it possible to be more responsive? Right now it checks the code when I press CTRL + S to save file. Is there an option to trigger it more often? Thanks!

Artur Jarosz
  • 81
  • 4
  • 14
  • Do you have the python extension installed? You should be able to configure which linter it is using in `settings.json` and it will lint your code as you're typing it. – Maximilian Burszley Nov 30 '18 at 16:37
  • Yes, I have. I have no problem with choosing linter. I can switch them. Problem is that they don't work in real time. For example, when I forget to put some whitespace I got an error but it disappears not straight after I correct it only when I save a file later on. – Artur Jarosz Nov 30 '18 at 16:41
  • I see your problem now. It looks like the linters are only executed on save as a default from the python extension. – Maximilian Burszley Nov 30 '18 at 16:45
  • I'm looking for the exact opposite I want checks an linting only when saving. I don't want my editor and linter waste CPU cycles to tell me not to use one letter variables when I just started typing in a variable name. – Calmarius Jul 29 '21 at 17:47

1 Answers1

1

You need a lint extension, most notably one for python.

On the left column of your IDE you will see a button that on hover it displays text saying extensions, click on it and look for one that says python and lint in the same extension. Many of this extensions do the same on different ways and some are just commercial or freemium.

You should be able to configure how hard you want your parameters/rules to be enforced by configuring this extension.

Have a look at this guide of steps to follow

You might find Python-autopep8 useful as well, which is ready made and you won't have to configure

Mr-Programs
  • 767
  • 4
  • 20
  • You don't need to install a python-specific linting extension because it's already built into the official python extension. You can modify the `python.formatting.provider` key in `settings.json`. This is set to `autopep8` as a default. – Maximilian Burszley Nov 30 '18 at 16:39
  • A correction to my previous comment: that is for formatting. There is a separate *linting* key which you need to change under `python.linting.pep8Enabled` – Maximilian Burszley Nov 30 '18 at 16:43
  • link is more oriented towards cofiguration which i found way to extense to put on a comment, theres a part that says Pep8 (pycodestyle) pep8 Disabled pep8Enabled as you can see tweaking this can be helpful – Mr-Programs Nov 30 '18 at 16:43
  • Thank you all for comments. So, I have added to my setting.json: "python.linting.enabled": true, "python.analysis.diagnosticPublishDelay": 10, "python.linting.pep8Enabled": true, "python.formatting.provider": "autopep8" Still, problems with [python] description are gone straight after I correct them but those with [pep8] stays until I save the file. – Artur Jarosz Nov 30 '18 at 17:02