Python in Visual Studio Code – December 2022 Release

Courtney Webster

We’re excited to announce that the December 2022 release of the Python and Jupyter extensions for Visual Studio Code are now available!

This release includes the following announcements:

  • Auto indentation with Pylance
  • Preview: Python in the browser
  • Community Highlight: Ruff

If you’re interested, you can check the full list of improvements in our changelogs for the Python, Jupyter and Pylance extensions.

Auto indentation with Pylance

The Pylance extension for VS Code is working to improve our auto indent feature through its deeper understanding of Python! This feature allows you to focus more on the logic of your code and less on formatting. Try it out in VS Code Insiders using the Pre-Release version of the Python extension! You can tell it has been enabled by verifying that the following setting has been automatically added in the User settings.json file (View > Command Palette and run “Preferences: Open User Settings (JSON)”):


 "[python]": {

        "editor.formatOnType": true,

    },

We’re turning this setting on by default over the next couple of months. If you have any issues or feedback, please let us know in the Pylance GitHub repository.

Preview: Python in the browser

You can now try our experiment running and debugging Python code in the browser within vscode.dev!

There’s a new VS Code extension that allows you to try running Python code in the Web using WebAssembly as an execution engine. Please note that this extension is being used for experimental and research purposes to gain an understanding of running Python code in the Web using WebAssembly and should not be used for production Python development as there are significant limitations.

Feel free to play around with this preview by following the steps below:

  • Open a Chrome based browser (e.g. Microsoft Edge or Google Chrome)
  • Navigate to a GitHub repository using the URL template https://insiders.vscode.dev/github/{username}/{repo}?vscode-coi=; replace {username} and {repo} as appropriate for your needs. If you need one, you can use https://insiders.vscode.dev/github/dbaeumer/python-sample?vscode-coi= . Ensure that the query parameter ?vscode-coi= is appended to the URL
  • Install the latest pre-release version of the Experimental - Python for the Web extension
  • Open a Python file
  • Execute the file by using the Editor’s Run menu

Picture shows options to Run or Debug Python files in WASM

  • Debug the Python file using the same Run menu
  • Create a launch config (e.g.)
    {
        "type": "python-web-wasm",
        "name": "Debug Active Python File",
        "request": "launch",
        "program": "${file}",
        "stopOnEntry": true,
        "console": "integratedTerminal"
    }
  • Start debugging using the launch configuration to play with debugging features

Community Highlight: Ruff

@charliermarsh, creator of the ruff linter, created an accompanying Ruff extension using the Python tools extension template. This VS Code extension provides support for the Ruff linter and currently ships with ruff==0.0.138. Once installed in Visual Studio Code, Ruff will be run on your code when you open or edit a Python file. Support includes linting that replaces uses of flake8, isort-compatible import sorting with Organize Imports, “Quick Fix” actions for auto-fixable violations equivalent to Ruff’s --fix support, and a Fix all command for automatically fixing auto-fixable violations.

Organizing imports using the Ruff extension

Moreover, you can configure Ruff to auto-fix violations on-save by enabling the source.fixAll action in settings.json:

{
    "editor.codeActionsOnSave": {
        "source.fixAll": true
    }
}

Just like Charlie, you can use the extension template to create a VS Code extension for your own favorite linter or formatter and do it by changing mainly Python code! For more information about the template, please reference our August 2022 Release and give the Ruff extension a try!

Other Changes and Enhancements

We have also added small enhancements and fixed issues requested by users that should improve your experience working with Python and Jupyter Notebooks in Visual Studio Code. Some notable changes include:

Try out these new improvements by downloading the Python extension and the Jupyter extension from the Marketplace, or install them directly from the extensions view in Visual Studio Code (Ctrl + Shift + X or ⌘ + ⇧ + X). You can learn more about Python support in Visual Studio Code in the documentation. If you run into any problems or have suggestions, please file an issue on the Python VS Code GitHub page.

1 comment

Discussion is closed. Login to edit/delete existing comments.

  • Mehdi Hussain 0

    Vscode with extensions really works awesome! I was using Anaconda earlier but luckily it turned out to be a great decision to use VScode. jupyter, prettier, and Blackbox are so far my favorite ones and exploring a few others as well. thanks for the info.

Feedback usabilla icon