Python in Visual Studio Code Improves 'Getting Started' Experience

Microsoft's dev team for Python in Visual Studio Code has smoothed the "getting started" experience for its main extension along with many other improvements in the regular monthly update, this for August 2022.

The team in addition to the main Python extension in the VS Code Marketplace, also develops and maintains the associated Jupyter extension. That main tool is a runaway success as it nears 62 million installs. That's way ahead of the second-most popular item with 42.7 million installs, which just happens to be the Jupyter tool. The next most popular extension is also associated with Python, the Pylance language server (35.2 million).

But it's the main Python tool whose getting started experience has been boosted.

"The Python extension walkthrough has been improved to more easily guide users to installing Python when needed, and selecting it in VS Code," said the team's Kartik Raj in an Aug. 4 blog post. "When Python is not installed on a Windows machine, selecting the 'Install Python' button from the walkthrough will open the Python app in the Microsoft Store. When on Linux or macOS, the displayed installation instructions will be automatically run in the terminal.

"Another improvement related to the getting started experience is that notifications for selecting the interpreter are now only shown when an interpreter is required (e.g. when running or debugging a file, or a tool such as a linter or formatter), and no longer on start-up. Other notification prompts have also been improved to be more precise about errors and suggested changes."

Automatic Debug Configurations for Web Apps
The update also includes new automatic debug configurations for projects that use Flask, Django or FastAPI, all web frameworks written using Python.

Fast API Debugging Configuration in Animated Action
[Click on image for larger, animated GIF view.] Fast API Debugging Configuration in Animated Action (source: Microsoft).

"When you open the Run and Debug view in VS Code (Ctrl + Shift + D or ⌘+ ⇧ + D) and there is no debugger configuration (i.e., no launch.json file) on your workspace, you will see an 'show all automatic debug configurations' option," Raj said. "If your project is a web application that follows the format expected by Flask, Django or FastAPI, once you click on that option you will be able to see debug configurations that were dynamically created to execute and debug your project. Now you can just select it to start catching all the bugs!"

Other improvements include:

  • Setting to configure the display of the interpreter information on the status bar: A new User setting called "python.interpreter.infoVisibility" controls when the selected interpreter information is displayed in the status bar. Devs can set "python.interpreter.infoVisibility": "always" on under User settings to always display the information no matter what file is opened. By default, however, it’s only displayed when Python-related files are open on the editor ("python.interpreter.infoVisibility": "onPythonRelated").
  • A new Python Tools extension template: The team provided a template to help developers create a VS Code extension for their favorite Python linter or formatter by changing mostly Python code, though some TypeScript work will be needed if more settings or custom logic will be added.
  • Remove all unused imports with Pylance: Devs can now use a code action to remove all unused imports when there is more than one library that is being imported but isn't used or called from anywhere in the code.
  • Double click to accept type hints with Pylance: This builds on previous work to add support for variable types and return types inlay hints when using the Pylance extension. Here, the team added support to accept the suggested annotations to code, such that coders can now double click on a hint to add the suggestion to their code.
  • Copy output image in Jupyter cells: Devs can now copy images from Jupyter notebooks output cells to the clipboard so they can be more easily shared outside of VS Code.
  • Go to most recently failed cell: "Another improvement introduced in the latest Jupyter extension release is the ability to navigate to the most recently failed cell. When you run all your cells and one fails, you can click on the 'Go To' button on the top of the editor and you will be taken to the one that halted the group execution."

The announcement post also lists many other changes and enhancements.

About the Author

David Ramel is an editor and writer for Converge360.

comments powered by Disqus


Subscribe on YouTube