Python in Visual Studio Code – November 2022 Release

Courtney Webster

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

This release includes the following announcements:

  • Migration to isort extension
  • Auto imports turned off by default with Pylance
  • Pylint and flake8 extensions recommendation
  • “Just My Code” for notebook cell debugging

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

 

Migration to isort extension

In our May 2022 release, we announced a new isort extension that works alongside the Python extension to sort imports. For example, when you open a file and the imports do not follow isort’s standards, it will display an error diagnostic and provide a code action to fix the import order. In this release, we are migrating users off of the built-in isort support by automatically installing the isort extension. This will make updates smaller and faster for users as we will only have to update the isort extension as needed, compared to shipping all isort-related files in the Python extension regardless of whether they changed.

 

Auto imports turned off by default with Pylance

Since auto imports were first implemented in Pylance, we’ve been getting a lot of feedback about how confusing and, sometimes, annoying it could be to have an import automatically added to a file when, for example, suggestions are accepted by accident. Starting this release, packages will no longer be imported automatically by default when using Pylance. If you’d like to re-enable auto imports for your Python projects, you can do so by adding the following setting to your settings.json file ( View > Command Palette… and run “Preferences: Open User Settings (JSON)): "python.analysis.autoImportCompletions": true, or by looking for python.analysis.autoImportCompletions in the settings UI (File > Preferences > Settings).

 

Pylint and flake8 extensions recommendation

In our previous releases, we announced new Pylint and Flake8 extensions that work in tandem with the Python extension through the Language Server Protocol (LSP) to provide linting. In this release, we’re starting to roll-out a notification that suggests those who are still using the pylint and flake8 features built into the Python extension to install these new extensions. Our long-term plan is to eventually remove the built-in support in favor of these separate extensions.

Use and install the Pylint extension prompt

 

“Just My Code” for notebook cell debugging

The “Just My Code” debug feature allows the user to determine whether the debugger will step through code from Python libraries, or will only step through user code. This has been enabled by default when debugging a notebook cell, and you can now set "jupyter.debugJustMyCode": false to disable it and allow stepping through library code. For the best experience, upgrade debugpy in your environment to >1.6.3. Previously, this setting was only respected for debugging using the Interactive Window. Now, it is respected in notebook editors as well.

 

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:

  • A new python.analysis.packageIndexDepths setting you can use to control Pylance’s indexing behavior. Check out Pylance’s settings documentation to learn more (pylance-release#2681).
  • You can now restart Jupyter notebook cell debug sessions. This feature is especially useful in a workflow where you debug, edit the cell, then restart the debug session to debug the cell again with your edits applied (vscode-jupyter#7670).

We would also like to extend special thanks to this month’s contributors:

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.

0 comments

Discussion is closed.

Feedback usabilla icon