News

What's New in Python in Visual Studio Code for February 2022

The regular monthly update to Python in Visual Studio Code is out with four main improvements.

The dev team for Python in VS Code manages the Python extension in the VS Code marketplace, providing IntelliSense, linting, debugging and so on. At more than 50 million installs, it's by far the most popular tool in the marketplace.

According to a Feb. 3 announcement, improvements to Python in VS Code affect Smart Selection, folding support, the Python interpreters list and Anaconda functionality.

Here are summaries of each feature:

Smart Selection
Thanks to Smart Selection via Pylance, developers can now use fewer keystrokes to select sections of code when using the keyboard. Pylance, which is now the default language server for Python in VS Code, provides IntelliSense and other language-specific functionality. "This was a highly requested feature, and it takes into account your code structure and heuristics to define the selection range," Microsoft said. Code selection can be expanded with various key combination commands, as shown in this animated GIF:

Smart Selection in Animated Action
[Click on image for larger view.] Smart Selection in Animated Action (source: Microsoft).

Folding Support
Pylance is also responsible for improved folding support, which is done by clicking on little arrow-like folding icons to show or hide code segments. "Previously, the folding regions were defined just by indentation, which was not ideal for some cases, for example, with multi-line strings as pointed out in our issue tracker. Now folding regions take into account semantic information appropriately (this includes #region comments)."

Improvements to the Python Interpreters List
The Python extension’s interpreters list now groups Python interpreters by type for easier identification. Microsoft said this new grouping scheme is similar to that used by to display kernels in the Jupyter extension.

Improvements when Using Anaconda
Using Anaconda environments is now easier in several ways. "Previously, there would be issues when debugging files and running tools using conda environments unless VS Code was initiated in an activated conda environment," Microsoft said. "To resolve several of these issues (#5559, #11205, #11638), the Python extension is using 'conda run' to execute files and tools."

All of the above and more are mentioned in the changelog, which shows these enhancements:

  • Add support for conda run without output, using --no-capture-output flag. (#7696)
  • Add an option to clear interpreter setting for all workspace folders in multiroot scenario. (#17693)
  • Public API for environments (proposed). (#17905)
  • Group interpreters in interpreter quick picker using separators. (#17944)
  • Add support for pylint error ranges. Requires Python 3.8 and pylint 2.12.2 or higher. (thanks Marc Mueller) (#18068)
  • Move pinned interpreter status bar item towards the right behind pythonInterpreterInfoPinned experiment. (#18282)
  • Move interpreter status bar item into the Python language status item behind pythonInterpreterInfoUnpinned experiment. (#18283)
  • Update Jedi language server to latest. (#18325)

The changelog also lists fixes and improvements to code health.

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