September 6th, 2024
heart2 reactions

Python in Visual Studio Code – September 2024 Release

Courtney Webster
Program Manager

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

This release includes the following announcements:

  • Django unit test support
  • Go to definition from inlay hints with Pylance

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

Django unit test support

We are excited to announce support for one of our mostrequested features: you can now discover and run Django unit tests through the Test Explorer!

In order to enable this feature, you will need to add aMANAGE_PY_PATH environment variable, pointing to your Django application’s manage.py file. To do so, you can follow these steps:

  1. Set"python.testing.unittestEnabled": true, in yoursettings.jsonfile.
  2. AddMANAGE_PY_PATH as an environment variable:
    1. Create a.env file at the root of your project.
    2. AddMANAGE_PY_PATH='<path-to-manage.py>' to the.env file, replacing<path-to-manage.py> with the path to your application’smanage.py file.

      Tip: You can copy the path by right clicking on the file in the Explorer view and selectingCopy Path.

  3. Add Django test arguments to"python.testing.unittestArgs": [] in thesettings.jsonfile as needed, and remove any arguments that are not compatible with Django.

Note: By default, the Python extension looks for and loads.env files at the project root. If your.env file is not at the project root or you are usingVS Code variable substitution, add"python.envFile": "${workspaceFolder}/<path-to-.env>" to yoursettings.jsonfile, so the Python extension can load the environment variables in this file when running and discovering tests. See ourPython environment variables docs for more information on environment variables.

Navigate to the Testing view, and select theRefresh Tests button to have your Django tests displayed!

Django tests displayed in the Test Explorer.

For troubleshooting tips, please see ourDjango testing docs. As you explore this newly added feature, please provide feedback and report any issues in ourvscode-python repo or by using thePython: Report Issue command.

Go to definition from inlay hints with Pylance

When enabling inlay hints with Pylance, you can now more conveniently navigate to a type’s definition throughCtrl+Click orCmd+Click when hovering over it.

Python type through an inlay hint hover showing Go to Definition by using Ctrl/Cmd + click

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:

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