April 4th, 2024
heart3 reactions

Python in Visual Studio Code – April 2024 Release

Courtney Webster
Program Manager

We’re excited to announce the April 2024 release of thePython andJupyter 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’sRun 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 thePython,Jupyter andPylance 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 alaunch.json for your web app. For Django, the Python Debugger extension looks formanage.py orapp.py files in the root or a subdirectory one level lower in your workspace. For Flask, the extension looks forwsgi.py,app.py, orinit.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 aDefault 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’sRun 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 thejupyter.executionAnalysis.enabled andnotebook.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

ThePython andPython Debugger extensions have adopted changes making it easier for you to report issues to our repos! Filing an issue with theReport 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 theReport Issue command for@vscode-python or@vscode-python-debugger, choosePython orPython 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 thePython extension and theJupyter 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 aboutPython support in Visual Studio Code in the documentation. If you run into any problems or have suggestions,please file an issue on thePython VS Code GitHub page.

Category
Topics
Share

Author

Courtney Webster
Program Manager

0 comments

Discussion is closed.

    Stay informed

    Get notified when new posts are published.
    Follow this blog
    youtube