Python in Visual Studio Code – February 2024 Release
This release includes the following announcements:
- Python debugger extension installed by default
- Create Environment option in the Python interpreter Quick Pick
- Jupyter’s built-in variable viewer
- New diagnostic rules with Pylance
- VS Code triggered breakpoints with Python
Python Debugger extension installed by default
The Python Debugger extension is now installed by default alongside the Python extension.
The Python Debugger extension aims to separate the debugging functionality from the main Python extension to prevent compatibility issues. This ensures that even as the Python extension drops support for older Python versions (e.g., Python 3.7), you can continue debugging projects with those versions without downgrading the Python extension. It also delivers platform-specific builds, ensuring you only receive the components relevant to your specific operating system, reducing download times and unnecessary overhead.
The Python Debugger extension enables all the functionality you are used to and more!
To ensure you are using the new Python Debugger extension, replace
"type": "python" with
"type": "debugpy" in your
launch.json configuration file. In the future, the Python extension will no longer offer debugging support, and we will transition all debugging support to the Python Debugger extension.
Create Environment option in the Python interpreter Quick Pick
You can now more conveniently create a Python environment from the Python interpreter Quick Pick. Run the Python: Select Interpreter command, and then select the Create Virtual Environment option to create a new virtual environment for your project.
Jupyter’s built-in variable viewer
The Jupyter extension has added an experimental variable viewer to the Run and Debug panel. You can enable this experience by adding
"notebook.experimental.variablesView": true in your User
settings.json file. This built-in variable view can be used to view variables from your notebook kernel, helping you monitor variables in your program as your code is run. This is especially helpful when debugging your code as you can monitor the value of your variables in real time.
The built-in variable viewer is still under active development. Feedback and suggestions are welcomed in the vscode-jupyter repo.
New diagnostic rules with Pylance
Pylance, which is powered by Pyright, used to display
reportGeneralTypeIssues diagnostics for a variety of typing issues in your code when type checking mode is enabled. This diagnostic rule has been modified in Pyright to allow for a more granular control over the diagnostics and is now available in Pylance Pre-Release. The
reportGeneralTypeIssues diagnostic has been broken down into the following new rules:
You can refer to the configuration documentation for more details about each of them.
VS Code Triggered Breakpoints with Python
VS Code has added support for triggered breakpoints! Triggered breakpoints are breakpoints that are automatically enabled once another breakpoint is hit. For example, this can be very useful when diagnosing failure cases in code that happen only after a certain pre-condition.
Triggered breakpoints can be set by right-clicking on line gutter, selecting Add Triggered Breakpoint…, and then choosing which breakpoint enables this one.
Support for triggered breakpoints is enabled for all languages, not just Python!
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:
- Fix duplicated suggestions for Python and avoid launching another language server in @vscode-jupyter#13596.
- Added support for multi-level pytest classes allowing for top-level classes to be displayed in the Test Explorer in @vscode-python#22520.
- Interpreter quick pick now displays the name of conda environments to make it easier to identify them in @vscode-python#21770.
- New Python Quick Start docs page to get you up and coding quickly!
We would also like to extend special thanks to this month’s contributors:
- @PopoDev Show name for conda environments created in the workspace in @vscode-python#22701
- @yilei Support range formatting when using Black 23.11.0+ in @vscode-black-formatter#380
Call for Community Feedback
As we are planning and prioritizing future work, we value your feedback! Below are a few issues we would love feedback on:
- Design proposal for test coverage in (@vscode-python#22827)
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.