February 28th, 2024
0 reactions

Python in Visual Studio Code – March 2024 Release

Courtney Webster
Program Manager

We’re excited to announce the March 2024 release of thePython andJupyter extensions for Visual Studio Code!

This release includes the following announcements:

  • NewAdd Imports Code Action heuristics setting
  • Automatically start your browser when debugging Django or Flask apps
  • Shell integration for the Python REPL
  • Language support for locally running Jupyter servers

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

NewAdd Imports Code Action heuristics setting

TheAdd Import Quick Fix (💡) , triggered when there are missing imports in your Python project, has been improved in the pre-release version of the Pylance extension! Pylance now uses heuristics to show only the top 3 high-confidence import options, prioritized based on: most recently used imports, symbols from the same module, symbols from the standard library, symbols from user modules, symbols from third-party packages, and finally sorting by module and symbol name. In the case where the 3 high-confidence import options aren’t what you are looking for, Pylance introduced a new Code Action,Search for additional import matches, which displays a quick pick menu that allows you to search for import options that prefix-match the missing import symbol.

Pylance Quick Fix and Code Actions for missing imports.

Additionally, Pylance introduced theChange spelling Code Action, which offers import suggestions for missing imports due to typos.

Fix code spelling Code Action with Pylance.

 

We plan to enable this new behavior by default soon. However in the meantime, you can enable it now by settingpython.analysis.addImport.heuristics : "true" in your settings.

Automatically start your browser when debugging Django or Flask apps

Developing and testing your Python web applications is now more convenient with thePython Debugger extension! You can now get the browser to automatically open when starting the debugger with Django or Flask apps, by settingautoStartBrowser: true in yourlaunch.json configuration:

{    "name": "Python Debugger: Flask",    "type": "debugpy",    "request": "launch",    "module": "flask",    "env": {        "FLASK_APP": "hello_app.webapp",        "FLASK_DEBUG": "1"    },    "args": [        "run"    ],    "jinja": true,    "autoStartBrowser": true}

Auto start browser for web apps using the Python debugger extension.

Shell integration for the Python REPL

We now have shell integration for Python REPL enabled on Mac, Linux and Windows (when using theWSL extension). When executing commands in the Python REPL, colored circle decorators will indicate whether the commands succeeded or failed. This also enables support for theTerminal: Run Recent Command command, allowing you to view and utilize the REPL’s command history. Additionally, this feature allows access to Python’s shell file history for all operating systems viaTerminal: Run Recent Command.

Shell integration support for the Python REPL.

Language support for locally running Jupyter servers

Previously, when connecting to local Jupyter servers, the Jupyter extension treated these servers as remote, and as a result the Pylance extension was unable to detect the installed packages. In this iteration, we made changes so that the Jupyter extension detects whether the connected Jupyter server is local or remote, and as a result Pylance is now able to provide richer language features based on packages installed within a local Python environment.

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:

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.

Author

Courtney Webster
Program Manager

Stay informed

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