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

Subscribe on YouTube