By default, VSCode has stopped using project installed static analysis tool. Now it relies on VSCode Flake8 Extension for this functionality. The extension has its own Flake8 linter embedded.
While this change is understandable, I am unsure how to configure flake8 plugins under the new setup.
Previously, when using flake8 installed in my virtual environment, I only needed to install the pep8-naming plugin to enable it.
Now I'm using the Flake8 VSCode extension and its bundled package. How do I configure the pep8-naming plugin now that the VSCode extension handles all the static analysis?
You cannot simultaneously use plugins and the built-in Flake8 within the Microsoft Flake8 extension.
To achieve this, you must install Flake8 and the desired plugin within your virtual environment and then configure VSCode to utilize them.
Install Flake8 and Plugins:
Within your virtual environment (venv
), install flake8
, pep8-naming
, and any other Flake8 compliant plugins you need. Include these in your development requirements file.
pip install flake8 pep8-naming
Configure VSCode:
In your settings.json
file, specify that the project should use the Flake8 installed in your environment:
"flake8.importStrategy": "fromEnvironment"
This setting directs the system to look for an installed Flake8 in the venv
. If the Flake8 package isn't found, it will default to the built-in version, which does not include plugins.
Note: One drawback of this approach is that Flake8 may operate more slowly when using the linter from the environment.
For further information, refer to this discussion.