Python in Visual Studio Code – September 2024 Release

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:
- Set
"python.testing.unittestEnabled": true,
in yoursettings.json
file. - Add
MANAGE_PY_PATH
as an environment variable:- Create a
.env
file at the root of your project. - Add
MANAGE_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.
- Create a
- Add Django test arguments to
"python.testing.unittestArgs": []
in thesettings.json
file 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.json
file, 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!
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.
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:
- You can now access theVS Code Native REPL for Python from the Command Palette (
Ctrl/Cmd + Shift + P
) usingPython: Start Native REPL
(@vscode-python#23727) - VS Code Native REPL for Python now starts at the project folder(@vscode-python#23821)
- Strings are now normalized when sending commands to the VS Code Native REPL(@vscode-python#23743)
- You can now restart the debugger when debugging tests through the debug control widget(@vscode-python#23752)
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 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
