Python in Visual Studio Code – June 2022 Release
This release includes improvements to:
- Localization support
- Python interpreter discovery
- Jupyter extension support on vscode.dev/github.dev
- Insiders program for Pylance
Improved localization support
The Python extension now supports translations in all the languages that VS Code supports. We have updated the way we get the text of our commands, notifications, and titles to use translations that are maintained by a localization team, to ensure that they are up to date and correct.
To try it out, you can change the display language in VS Code by running the “Configure Display Language” command in the command palette (Ctrl + Shift + P or ⌘ + ⇧ + P).
Improvements in Python interpreter discovery
We also made improvements to when discovery of Python interpreters is triggered.
Previously, the Python extension would try to find Python interpreters every time it activated/loaded. Starting in this release, interpreter discovery is only triggered when a new folder or workspace is opened for the first time, when the “Python: Select Interpreter” command is triggered, and when the interpreters list is refreshed. This leads to much faster load times and startup of features like the language server.
Note that if the Jupyter extension is installed/enabled, discovery is still triggered by Jupyter at startup. We’re working towards improving this flow in the future.
New Jupyter extension features on vscode.dev/github.dev
We’ve made progress on supporting more of the core functionality in the new web version of the Jupyter extension.
This month we ported the following features to the web extension:
- https support
- kernel completions
- notebook debugging
- variable viewing
- interactive window
If you’d like to experiment with the functionality, you can launch Jupyter from your local machine with the following:
jupyter notebook --no-browser --NotebookApp.allow_origin_pat=https://.*\.vscode-cdn\.net
You can then connect to it using the “Jupyter: Specify Jupyter server for connections” command from within vscode.dev.
For more information and for providing feedback, see this discussion item.
Pre-release Pylance extension
The Pylance extension offers an Insiders program, where you can get preview updates and try the latest features and bug fixes earlier on. Before this release, one would opt into it via a setting, and then every week a new build would be downloaded and installed, and a prompt would be displayed to reload the window to enable the new update.
Given that the Python extension successfully migrated its insiders program in the March 2022 release to pre-release versions, we’re now doing the same for Pylance to provide a smoother opt-in and upgrade experience. You can install a pre-release version by opening the extension’s view in VS Code (Ctrl + Shift + X or ⌘ + ⇧ + X), searching for Pylance, and opening the Pylance extension. If you already have the extension installed, you will be able to click on the “Switch to Pre-Release Version” button next to the “Uninstall” button:
If you don’t have it installed, you will be able to click on the down arrow next to the Install button and select “Install Pre-Release Version”:
If you were part of the Insiders program and had the “pylance.insidersChannel” setting set to “daily”, you will automatically start using the pre-release versions of the Pylance extension. The setting will also be removed as it’s no longer supported.
What would Brett do?
The Engineering Manager of the Python extension and Python Steering Council member Brett Cannon has created a new experimental extension for setting up Python environments, called WWBD (which stands for “What would Brett do?”).
Through a command called “WWBD: Create environment”, it offers a very opinionated flow of creating a virtual environment using venv, and automatically installing dependencies if they’re listed in a requirements file on the workspace.
We’re looking for feedback on this experience at the repository, as we explore the possibility of integrating this flow into the Python extension itself in the future.
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:
- Experimental Feature: Pylance now treats each Jupyter notebook cell as a separate document rather than concatenating the cells together into a single document. It has the potential to fix a lot of Pylance notebook behaviors. It can be enabled by setting ”python.pylanceLspNotebooksEnabled”: true.
- Improve information collected by the “Python: Report Issue” command. (vscode-python#19067) .
- Jupyter notebooks no longer freeze on typing or executing (pylance-release#2783).
- Show completion suggestions for overriding inherited class variables (pylance-release#2059).
- Pylance now gets the stubs from the repo maintained by pandas-dev. Please open pandas stub issues there going forward (python-type-stubs#208).
We would also like to extend special thanks to this month’s contributors:
- djplt: Make the cursor focus automatically switch to the terminal after clicking the run button (vscode-python#14851).
- Eric Wieser: Added alert box styling for notebooks (vscode-jupyter#10034).
- Dr-Irv: Improvements to pandas stubs (python-type-stubs#194).
- Denis Rosset: Improvements to matplotlib stubs (python-type-stubs#197).
- abbymconnell: Added trailing Commas in jsno noon example (vscode-isort#48).
- Root Please: Fixed argv duplication bug (vscode-black-formatter#57).
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.