December 7th, 2023
heart3 reactions

Python in Visual Studio Code – December 2023 Release

Courtney Webster
Program Manager

We’re excited to announce the December 2023 release of the Python and Jupyter extensions for Visual Studio Code!

This release includes the following announcements:

  • Configurable debugging options added to Run button menu
  • Show Type Hierarchy with Pylance
  • Deactivate command support for automatically activated virtual environments in the terminal
  • Setting to turn REPL Smart Send on/off and a message when it is unsupported

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

Configurable debugging options added to Run button menu

The Python Debugger extension now has configurable debug options under the Run button menu. When you select Python Debugger: Debug using launch.json and there is an existing launch.json in your workspace, it shows all available debug configurations you can pick to start the debugger. In the case you do not have an existing launch.json, you will be prompted to select a debug configuration template to create a launch.json file for your Python application, and then can run your application using this configuration.

Gif demonstrating configurable debug options in the Run button menu.

Show Type Hierarchy with Pylance

You can now more conveniently explore and navigate through your Python projects’ types relationships when using Pylance. This can be helpful when working with large codebases with complex type relationships.

When you right-click on a symbol, you can select Show Type Hierarchy to open the type hierarchy view. From there you can navigate through the symbol’s subtypes as well as super-types.

GIF demonstrating Pylance Show Type Hierarchy on Python project.

Deactivate command support for automatically activated virtual environments in the terminal

The Python extension has a new activation mechanism that activates the selected environment in your default terminal without running any explicit activation commands. This is currently behind an experimental flag and can be enabled through the following User setting: "python.experiments.optInto": ["pythonTerminalEnvVarActivation"] as mentioned in our August 2023 release notes.

However, one problem with this activation mechanism is that it didn’t support the deactivate command because there is no inherent activation script. We received feedback that this is an important part of some users’ workflow, so we have added support for deactivate when the selected default terminal is PowerShell or Command Prompt. We plan to add support for additional terminals in the future.

Gif demonstrating auto-activation of a Powershell terminal and using the deactivate command.

Setting to turn REPL Smart Send on/off and a message when it is unsupported

When attempting to use Smart Send via kbstyle(Shift+Enter) on a Python file that contains unsupported Python code (e.g., Python 2 source code), there is now a warning message and a setting to deactivate REPL Smart Send. Users are also able to change their user and workspace specific behavior for REPL Smart Send via the python.REPL.enableREPLSmartSend setting.