News

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

Featured

  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

  • What's New for Python, Java in Visual Studio Code

    Microsoft announced March 2024 updates to its Python and Java extensions for Visual Studio Code, the open source-based, cross-platform code editor that has repeatedly been named the No. 1 tool in major development surveys.

Subscribe on YouTube