Python in Visual Studio Code – February 2023 Release

Courtney Webster

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

This release includes the following announcements:

  • Automatic environment selection when VS Code is launched from an activated terminal
  • Select requirements files or optional dependencies with the Python: Create Environment command
  • Preview: Improved IntelliSense support for pytest with Pylance
  • Jupyter kernel picker improvements

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

Automatic environment selection when VS Code is launched from an activated terminal

When a user launches VS Code via the terminal with a conda or virtual environment already activated, VS Code now detects that activated environment. Depending on the type of environment, VS Code either auto-selects the environment itself, or asks the user if they would like to select the environment that is present. This feature aims at improving your workflow by auto-selecting the environment rather than requiring manual selection.

Conda environment auto-selection

Select requirements files and optional dependencies with the Python: Create Environment command

We are continuing to improve our Python: Create Environment command based on your feedback! Previously, when a user created an environment with the Python: Create Environment command, the command searched for common requirements and dependency files and loaded them into the environment automatically. Now, the Python: Create Environment command finds requirements files in the workspace folder, and allows users to multi-select any number of requirements to install in a quick pick.

Create Environment with requirements.txt files

Alternatively, the Python extension detects and reads the optional dependencies provided in the [project.optional-dependencies] table of the pyproject.toml file. We then perform an installation of any selected optional dependencies along with using the pip install --editable . command (performing an editable install will become conditional on their being a [build-system] table in pyproject.toml in a future release). This is integrated as a quick pick in the Python: Create Environment command.

Create Environment with requirements.txt files

Preview: Improved IntelliSense support for pytest with Pylance

We’re excited to announce support for pytest fixtures and parameterization in the pre-release version of Pylance! This update includes powerful features that can help you work more efficiently and effectively when writing and maintaining clear, concise and easy to understand tests with pytest.

You can more conveniently navigate and read through your tests thanks to added support for go to definition and find all references, which also enables quick updates with symbol rename (F2):

Using `Go to definition` to rename Pytest symbols

Pylance also provides completions for pytest fixtures and for parameterized arguments, to help you write your tests more efficiently: Completions for pytest parameterized arguments

Adding type hints to your pytest fixture parameters can help further improve readability of your tests and catch errors before they become a problem. Pylance now offers two features that make this process more practical: you can trigger code actions (Cmd + . on macOS, Ctrl + . on Windows/Linux) to annotate the types of your pytest parameters, or even enable inlay hints through the "python.analysis.inlayHints.pytestParameters" setting (and then just double click a hint to insert it into your code).

Pytest fixture inlay hints Pylance will also infer the types of parameterized pytest arguments, based on the parameter values provided to the decorator: Pylance displaying inferred type for pytest parameterized arguments

You can try these updates by installing the pre-release version of the Pylance extension, and report any issues you may encounter at

Jupyter kernel picker improvements

We continued to improve the MRU (Most Recently Used) kernel picker. It can be enabled by setting "notebook.kernelPicker.type" to "mru". Kernels that are not used will be moved into a secondary picker “Select Another Kernel…”. This picker will group all kernels by their source (for example: “Jupyter Kernel”, “Python Environment”, etc.) when you have latest Jupyter extension and Python extension installed.

Notebook Kernel Picker

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:

  • Join Selected Cells (kb(notebook.cell.joinSelected)) to merge multiple selected cells into one cell in Jupyter Notebooks
  • Fallback rendering of output to a supported mimetype in Jupyter (vscode-jupyter#8635)
  • New refactor.extract code action kinds with Pylance: refactor.extract.method and refactor.extract.variable (pylance-release#3803)

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.


Discussion is closed.

Feedback usabilla icon