Python in Visual Studio Code – August 2023 Release
This release includes the following announcements:
- Python extension Dev Container for Contributors
- Debug configuration for running Python files with arguments
- Npm package for the Python extension API
- Error-tolerant pytest discovery
Python extension Dev Container for Contributors
There is now a Dev Container in the source repo of the Python extension. Using this customized dev container, contributors can open the Python extension repository in GitHub Codespaces, and start working on developing and testing the Python extension with no other installation required. Since we’ve enabled pre-builds, the Dev Container will load instantly.
Python versions 3.7, 3.8, 3.9, 3.10, and 3.11 are pre-installed so you can readily switch between Python versions using pyenv. The dev container is also configured to install any required extensions for development, including Pylance and Black formatter extensions.
Debugger configuration for running files with arguments
The new Debugpy extension now provides a “Python File with Arguments”
launch.json configuration, which is useful when you want to provide different input values for your Python file without the need to modify your code or the debugger configuration each time you run it.
To use this configuration, make sure you have the Debugpy extension installed. Then open the Run and Debug view by pressing
Ctrl + Shift + D or
⌘ + ⇧ + D and click on either Create a launch.json file or the gear icon to access the
launch.json file. Select Debugpy, and then select Python: File with Arguments from the available configurations.
Then, open the Python file that you want to debug, which requires command-line arguments. To start debugging, press
F5, or Run > Start Debugging. A prompt will appear, allowing you to enter the desired arguments that should be passed to the Python file.
After entering your arguments, press Enter, and the debugger will start, letting you step through your code!
Npm package for the Python extension API
The Python extension now provides an npm package to make it easier for other extension authors to access and track changes in the Python extension API. Check out the @vscode/python-extension npm module to work with Python environments available on your machine.
Error-tolerant pytest discovery
The Test Explorer panel now supports error-tolerant pytest discovery as a feature included in our new testing architecture. If pytest encounters a manageable error during discovery, such as an unknown import, all remaining tests will still be discovered outside the file containing the error. This feature is only available on the new testing rewrite behind an experimental feature. The rewrite is currently active for 100% of pre-release users and 25% of release users, but will be rolled out universally in the near future. In the meantime, you can continue to opt in or out of the rewrite with the
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:
- Import resolution errors show more information about the environment in use (@pylance-release#4368).
- Removal of the Create Environment button in dependency files will be rolled out to 100% of users based on feedback (@vscode-python#20982).
- Run file in dedicated terminal re-added as a run configuration (@vscode-python#21282).
We would also like to extend special thanks to this month’s contributors:
- @Imgarret helped file issues and created test cases for test classes, erroring, and skip flags for pytest related to the new testing rewrite (@vscode-python#21578 and @vscode-python#21579).
- @Jammf made their first contribution to vscode-mypy to fix errors when using –follow-imports=normal (@vscode-mypy#76).
- @PeterJCLaw made their first contribution to vscode-mypy to remove follow-imports argument which may conflict with projects (@vscode-mypy#90).
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:
- Support viewings for numpy and pickle files natively by double-clicking on them: @vscode-python#21443
- Add support for installing
requirements.txton current virtual environment by right-clicking on the file: @vscode-python#21555
- Dynamic module path in
Additionally, as a reminder, issues with the
feature-request label require 7 👍 upvotes within 60 days of opening to issue to gauge community interest. We use this as another way to prioritize upcoming work.
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.