Are you looking to set up a Python formatter and linter in Visual Studio Code (VS Code)? If you've recently tried to search for this information, you may have encountered outdated tutorials:
Well, things have become much simpler!
0. Install Python extension
1. Install Black Formatter extension
2. Install Flake8 extension
3. Configure Black
In the .vscode/settings.json file add editor.defaultFormatter and editor.formatOnSave settings:
{
    //...
    "[python]": {
        "editor.defaultFormatter": "ms-python.black-formatter",
        "editor.formatOnSave": true,
      }
    //...
}
4. Configure Flake8 (Using Black with Flake8)
Add the .flake8 file (project folder):
[flake8]
max-line-length = 88
extend-ignore = E203, E704
That's it! Enjoy hassle-free Python development with these extensions in place!

    
Top comments (0)