Python in Visual Studio Code – May 2022 Release
We’re excited to announce that the May 2022 release of the Python and Jupyter Extensions for Visual Studio Code are now available!
With this release we’re introducing three new extensions: Black, isort, and Jupyter Powertoys.
As mentioned before, our team is working towards breaking the tools support we offer in the Python extension into separate extensions, with the intent of improving performance and stability.
We now have a new extension for Black, the Python formatter. Similar to the pylint extension, this new extension uses the Language Server Protocol to provide formatting support, and it ships with the latest version of Black – so you’re no longer required to have it installed in a Python environment.
You can try this new extension out today by installing it from the marketplace. Then open a Python file, right-click on the editor and select “Format document with…”. You can also run the “Format document with…” command from the Command Palette (Ctrl + Shift + P or ⌘ + ⇧ + P). If you have any issues or feature requests, you can file them at the extension’s GitHub repository.
We also have a new extension for sorting imports with isort. When you open a file and your imports don’t follow isort’s standards, it will display an error diagnostic and provide a code action to fix the import order.
Jupyter Notebooks on the browser
The Jupyter extension can now be installed as a web extension for use with vscode.dev. Functionality is currently limited with support only for notebooks (.ipynb files) being run on Jupyter servers that do not require https.
If you’d like to experiment with the functionality, launch Jupyter from your local machine with:
jupyter --no-browser --NotebookApp.allow_origin_pat=https://.*\.vscode-cdn\.net
And connect to it using the command Jupyter: Specify Jupyter server for connections.
There are a number of features the team will be enabling in coming releases, including:
- ‘https’ based servers
- Data viewing
- Variable viewing
- Interactive window
- Plot viewing
Jupyter Powertoys extension
The Jupyter team is excited to announce the Jupyter Powertoys extension that provides experimental functionality for working with Jupyter notebooks. In its first release, the follow features have been prototyped:
- Kernel management panel
- Contextual help
- Execution grouping
We’d love for you to take these for a spin and let the team know what you think so that they can become a supported feature someday!
For more information, refer to the README in the vscode-jupyter-powertoys repository.
Jupyter kernel improvements
A number of updates were made to kernel handling:
- To make it more obvious when a kernel has crashed, the extension now displays this information in cell output.
- There is now troubleshooting guidance in cell output when certain known errors are detected during execution.
- Solving kernel execution problems can be a tricky and time-consuming process. So, we’ve put together a troubleshooting section on our wiki that we hope can help guide you to a solution quicker. Of course, our GitHub Discussions forum can be a great resource for obtaining help 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:
- Changing language servers no longer requires a window reload (vscode-python#18884)
- Fix support for selecting shell-like interpreter paths which may not exist on filesystem (vscode-python#18920)
- Renaming a method with Pylance will rename all overridden methods as well. (pylance-release#813)
We would also like to extend special thanks to this month’s contributors:
- Quan Zhuo: Fix download failure for prebuilt ripgrep binary when build from source (https://github.com/microsoft/vscode-python/issues/19036vscode-python#19036
- Dr-Irv: Improved IntelliSense when using pandas thanks to several pandas stub fixes (python-type-stubs#186, python-type-stubs#187, python-type-stubs#188, python-type-stubs#190)
- sunyinqi0508: Fix for errors when file paths contain special characters (vscode-python#18829)
- Caphosra: Replace `Buffer` constructors with safer methods to reduce security concerns. (vscode-jupyter#9562)
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.