News

VS Code Gets a 'Most Heavily Requested Feature' for Python

The regular monthly update for Python in Visual Studio Code sees the dev team adding "one of our most heavily requested features," a new rename factoring experience.

The experience comes via Pylance, the code editor's new language server extension. The simple and lightweight VS Code editor is turned into more of a full-fledged IDE with the help of a vast marketplace of extensions including language servers, which provide language-specific features such as autocomplete, error-checking (diagnostics), jump-to-definition and so on.

That's important for Python coders because the Python extension is far and away the most popular tool in the marketplace with more than 47 million installs. In fact, Pylance is the No. 4 item in terms of popularity, while another Python-related tool, Jupyter, is No. 2. So Python tools take three of the top four spots and account for more than 88 million installs.

With the December 2021 update to the Python extension, Pylance is put to work to improve that aforementioned "rename factoring experience." That simply means that now, when a developer renames a Python file or module, Pylance will offer to rename all of the instances in the developer's code, provided they approve of the proposed changes that Pylance presents. Formerly, said developer needed to do all that renaming work manually.

A screenshot showing Module Renaming in Animated Action
[Click on image for larger, animated GIF view.] Module Renaming in Animated Action (source: Microsoft).

"If you want to customize the references to be updated, you can toggle check boxes at the line or file level at the preview stage before accepting the changes," said Savannah Ostrowski, program manager, Pylance, in a Dec. 9 blog post about the update. "You can also change your mind after seeing what would be changed at the preview stage and discard all changes. With this preview, you can feel even more confident in the changes that are being made to your code and still save time when refactoring."

Pylance is also instrumental in providing other new functionality: Syntax error detection and limited IntelliSense support when working in virtual or untrusted workspaces. "Just like when using github.dev or vscode.dev, you can now take advantage of a series of editing features you might want when exploring a codebase virtually, or when inspecting the workspace locally to decide whether you'll mark it as trusted," Ostrowski said.

She also noted that the tool's debugger, debugpy, will no longer support Python 2.7 local debugging starting next month, so this update is the last release for which that will be available, though remote debugging will still work if debugpy is attached to a remote process running Python 2.7. The team earlier announced that the debugger's support for Python 2 would end, supporting only Python 3 in 2022.

The post also calls out a community (non-Microsoft) extension from Don Jayamanne, a Microsoft employee who also just happens to have created the Python tool in the first place before being hired by Microsoft (who also hired the creator of Python itself, Guido van Rossum).

"With the Python environment manager, you can open the manager view and see information on multiple Python environments located on your machine -- even virtual environments not located in your workspace," Ostrowski said. "You can then check which packages are installed in that environment as well as their versions. You can also create multiple terminals for different environments -- once you click on the terminal icon next to an environment, it will automatically activate it."

About the Author

David Ramel is an editor and writer at Converge 360.

comments powered by Disqus

Featured

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube