April 4th, 2024

Python in Visual Studio Code – April 2024 Release

Courtney Webster
Program Manager

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

This release includes the following announcements:

  • Improved debug config flow for Flask and Django
  • Module and import analysis on Jupyter’s Run Dependent Cells with Pylance
  • Hatch environment discovery
  • Automatic environment selection for pipenv, pyenv, and Poetry projects
  • Report Issue command improvements

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

Improved debug config flow for Flask and Django

Creating launch configurations for Flask and Django apps just got easier! Improvements have been made to detect possible startup files in your workspace when creating a launch.json for your web app. For Django, the Python Debugger extension looks for manage.py or app.py files in the root or a subdirectory one level lower in your workspace. For Flask, the extension looks for wsgi.py, app.py, or init.py files that contain the declaration of a Flask application (for example, app = Flask()). If none of those files are not found in the project, the dropdown shows a Default option for the corresponding project type, even though that file may not be present.

In the case your file was not detected, you can enter the file path directly or browse other files in your directory.

Gif of the debug configuration flow for a Flask app.

Module and import analysis on Jupyter’s Run Dependent Cells with Pylance

Dependency analysis for Jupyter cells has improved with the latest Pylance pre-release. With these changes, Pylance aids Jupyter in understanding module imports, which is especially useful when you have a cell that imports a module that was defined in a previous cell.

To enable this feature, install the latest Pylance pre-release in VS Code Insiders, and enable the jupyter.executionAnalysis.enabled and notebook.consolidatedRunButton settings.

Hatch environment discovery

Hatch environments are now discovered and activated, by default, similar to other common environments, such as Venv, Conda, and Poetry. Furthermore, in the case of Hatch where an explicit environment identifier is not registered, the extension is able to determine the environment type (Hatch) from the environment locator.

Automatic environment selection for pipenv, pyenv, and Poetry projects

If your workspace contains a pipenv, pyenv, or Poetry environment, the corresponding environment is now automatically selected for your workspace. Previously, the extension correctly discovered these environments, but selected the default global interpreter, requiring you to manually select the appropriate environment for your workspace. Now, the Python extension infers the default environment based on its presence and any corresponding configuration files. For example, in the case of pyenv, the extension looks at the .python-version file to automatically select the appropriate interpreter for the workspace.

Report Issue command improvements

The Python and Python Debugger extensions have adopted changes making it easier for you to report issues to our repos! Filing an issue with the Report Issue command (workbench.action.openIssueReporter) does most of the heavy lifting, prompting you for additional info so our team can efficiently triage the problem you are encountering.

To file an issue using the Report Issue command for @vscode-python or @vscode-python-debugger, choose Python or Python Debugger respectively from the extension dropdown.

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:

  • Better error messages when “Move to file” refactoring fails in @pylance-release#4345
  • REPL Smart Send (python.REPL.enableREPLSmartSend) is now enabled by default

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

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:

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.

Category
Python
Topics
python

Author

Courtney Webster
Program Manager

0 comments

Discussion are closed.