Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Real-time linting of Python with VSCode

Recently I'm using VSCode as my Python IDE, and I install DonJayamanne/pythonVSCode, which supports linting. However, the linter only works when saving, but what I want is real-time linting. The workaround suggested by the author is to set files.autoSave to on, so that the linter will work whenever the file is automatically saved. There's a relevant discussion on Github, for your reference.

Since I don't want to turn on auto-save function, is there any way to do real-time linting of Python with VSCode? Or is there any suggested extension?

like image 690
amigcamel Avatar asked Jan 30 '26 08:01

amigcamel


1 Answers

EDIT4, 14 Apr 2024

Enable format on save option in UI setting globally.


EDIT3, 13 Apr 2024 Its just enough for 1.88.1 version

{
    "editor.formatOnSave": true
}

EDIT2, 27 Mar 2024

Just only use this config to real time linting.

{
    "python.defaultInterpreterPath": "/usr/bin/python3",
    "editor.formatOnSave": true
}

Installed extensions are

  • python
  • pylint
  • pylance
  • python debugger
  • autopep8

EDIT1 Update 4 Jul 2022 New version of python extension deprecates "python.pythonPath" and suggest to use this instead.

"python.defaultInterpreterPath": "/usr/bin/python3",

Put these lines in .vscode/settings.json

{
    "python.linting.pylintEnabled": true,
    "python.linting.enabled": true,
    "python.pythonPath": "/usr/bin/python3",
    "editor.formatOnSave": true
}

And install autopep8 package.

Use pip to install it

python3 -m pip install autopep8

Or in Debian based as python3-autopep8 exists in repo you can run

sudo apt install python3-autopep8

And then python linting on vscode will work.

Also, the Warning menu will activate.

Hint that I set run linter onsave. warning

like image 69
EsmaeelE Avatar answered Feb 02 '26 01:02

EsmaeelE



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!