Python in Visual Studio Code – October 2022 Release

Courtney Webster

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

This release includes the following announcements:

  • Simplified project setup with new Create Environment command
  • Include, exclude, and ignore paths can now be provided for Pylance
  • A new autopep8 extension in preview
  • Python file cell folding
  • Tag and parameterize notebook cells
  • New type checking status button for Pylance
  • Grace Hopper Conference and Open Source Day participation

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


Simplified project setup with new Create Environment command

A new Create Environment command has been added that automatically creates a virtual environment or Conda environment for your Python workspace. You can trigger the command through the Command Palette (Ctrl + Shift + P or ⌘ + ⇧ + P), select whether you want to create a new virtual environment with venv or a Conda environment, and, finally, select the desired interpreter for your project. The command will also install necessary packages outlined in a requirements/dependencies file, such as requirements.txt, pyproject.toml or environment.yml, located in the project folder. We hope this new feature streamlines the environment creation process and encourages the utilization of environments for coding best practices.

Create a virtual environment with venv using the Create Environment command


Include, exclude, and ignore paths can now be provided for Pylance

Pylance has added an enhancement that allows users to include, exclude, and ignore paths via VS Code settings. Within each of these settings, you can specify paths of directories or files that should be included, excluded, or ignored for Pylance diagnostic output.

Look for these new settings in the VS Code settings panel:

  • python.analysis.include
  • python.analysis.exclude
  • python.analysis.ignore

Description of the python.analysis.exclude setting as shown by in VS Code's setting UI page.


A new autopep8 extension in preview

We are continuing to add to our growing extension library with a new autopep8 extension now in preview! As with our pylint, black, isort, and flake8 extensions, the autopep8 extension uses the Language Server Protocol to provide formatting support. Since it ships with the latest version of autopep8, it is not required to be installed in a Python environment.

Format code with autopep8

You can now give the autopep8 extension a try by downloading it from the marketplace. If you have any issues or feature requests, you can file them in the autopep8 extension’s GitHub repository.


Python file cell folding

All “cells” within a Python file denoted with # %% markers can now be folded in the editor. This makes it easy to collapse sections of your code so you can navigate your Python file without extensive scrolling.

Folding cell marked with # %% in a Python file


Tag and parameterize notebook cells

You can now add tags and parameterize notebook cells directly in the notebook editor without opening the json format of the document – a feature provided in the Jupyter extension. This feature enables things like parameterization of notebooks for papermill or nbconvert, for creating slideshows directly from your notebook!

Tag added to notebook for parameterizing cell.



New type checking status button for Pylance

You can now set the type checking mode for Pylance through the language status button in the status bar, at the bottom of the editor. This setting can be switched between off, basic, and strict.

You can learn more about type checking settings and other Python Language Server settings within Visual Studio Code Docs.



Grace Hopper Conference and Open Source Day participation

On September 16th, our team participated in Open Source Day! Open Source Day is an all-day hackathon and a part of Grace Hopper Celebration, the largest celebration of women in Open Source. During this event, attendees work with peers as well as experienced mentors to contribute to several open source projects.

We’d like to thank all of the mentors who participated on this event alongside us, and to each one of the participants who contributed to our projects:

There are a number of “quick fix” feature issues open for those who are looking to contribute! We hope to encourage the Python community to contribute and maintain the extension in any way they can. You can find these issues labeled as good first issue within the pylint, flake8, isort, and black repositories. To learn about additional ways to contribute, check out Dawn Wages’ blog post on how you can contribute to open source with the Pythonistas at Microsoft!


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:

  • HTML headers in Markdown cells can now be detected and rendered in the notebook outline views
  • Improved command interaction for Interactive Window. The interactive.input.focus command will now give focus to the most recently used Interactive Window’s input box. For example, you can Ctrl + Up Arrow to select the last run “cell” in the Interactive Window and DD to delete the cell (with custom keyboard shortcuts). You can also Ctrl + Z to undo delete cell command.
  • “Remove all unused imports” code action now only removes top level imports and “Remove unused import” code action now removes leading whitespace (pylance-release#3181)
  • Pylance auto completion list shows names of empty modules (pylance-release#3293, pylance-release#3289)
  • Diagnostics are no longer displayed within IPython cell magics (pylance-release#3327)

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

  • amyreese created the ufmt extension using the newly released extension template. The template can be used to create VS Code extension’s for your favorite linter or formatter by changing mainly Python code. For more information about the template, please reference our August 2022 Release and give the ufmt extension a try!

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.