Python in Visual Studio Code – November 2022 Release
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
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.
“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.packageIndexDepthssetting 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:
- @jjmacklin: Feature/trailing whitespace (pylint#203)
- @anu-ka: Added quick fix for “tab after keyword” (flake8#65)
- @Bobronium: Settings to notify user of formatting errors (black-formatter#59)
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.