This post was written by Luciana Abud, Program Manager for the Python Extension in Visual Studio Code
We are pleased to announce that the January 2019 release of the Python Extension for Visual Studio Code is now available. You can download the Python extension from the Marketplace, or install it directly from the extension gallery in Visual Studio Code. You can learn more about Python support in Visual Studio Code in the documentation.
In this release we have closed a total of 62 issues, including:
- IPython console support in the Python Interactive window
- Support for running an entire file in the Python Interactive window
- Problems for failed tests when using pytest (thanks Chris NeJame)
- Much faster outline when using the Python Language Server
Keep on reading to learn more!
IPython console support in the Python Interactive window
The data science experience was first introduced in the last October release, and one of the top feedback requests we’ve heard was to provide the ability to iterate rapidly by experimenting with code in an interactive console environment. In this update, we extended the Python Interactive window with IPython console support by allowing code to be typed in and executed directly in the window. You can now use the enhanced Interactive window standalone as an IPython console, or send code from the editor for execution.
Here’s how to use it in a nutshell:
- To get started, run the command Python: Show Python Interactive window in the Command Palette (View -> Command Palette).
- Directly type in code, press “Enter” for a new line, and “Shift-enter” to run the code.
Run an entire file in the Python Interactive window without cells defined
Being able to run code in the Python Interactive window without having to define cells is no doubt one of the most requested features. This update enables running the entire files in the Interactive window without cell definitions.
To run the entire file, simply use the command Run Current File in Python Interactive window in the Command Palette. Your code will be executed with results displayed in the Python Interactive window.
We’ve also heard requests to run the current code selection / line in the editor, and this will be coming next in a future update.
Diagnostics for failed tests with pytest
This release also includes an enhancement to unit tests run with pytest: you can now see failed tests in the problems window. You can also double click lines to navigate to the failed test method and the exact failing line. The correspondent line in the editor will be selected, allowing you to easily identify and edit it.
As before, you can also see failed tests highlighted with pass/fail icons in the editor. You can hover these icons to see the errors navigate to the failing test method/line, just like in the problems window.
We’d like to thank community contributor Chris NeJame for implementing this new feature. Contributions to the Python extension are always welcome! If you’re interested, check our contributing guide to learn more.
Much faster outline view with the Python Language Server
We also made improvements to the outline view when using the Microsoft Python Language Server. The Outline view could often take a long time to load or even time out, and now with the Language Server It now loads consistently fast, and cases where symbols would appear duplicated were fixed.
As a reminder, the Language Server was released as a preview the last July release of the Python extension. To opt-in to the language server, change the python.jediEnabled setting to false in File > Preferences > User Settings. We are working towards making the language server the default in future releases.
Other Changes and Enhancements
We have also added small enhancements and fixed issues requested by users that should improve your experience working with Python in Visual Studio Code. The full list of improvements is listed in our changelog; some notable changes include:
- Add the python.pipenvPath config setting (#978)
- Improvements to automatic selection of the python interpreter. (#3369)
- Indent on enter after line continuations. (#3284)
- Activate pipenv environments in the shell using the command pipenv shell. (#2855)
- Fix bug affecting multiple linters used in a workspace. (thanks Ilia Novoselov) (#2571)
- Validate Mac Interpreters in the background. (#3908)
- Activate any selected Python Environment when running unit tests. (#3330)
- Use Pylint message names instead of codes (thanks to Roman Kornev) (#2906)
Be sure to download the Python extension for Visual Studio Code now to try out the above improvements. If you run into any problems, please file an issue on the Python VS Code GitHub page.