Now Reading
A New Python Language Support In Visual Studio Code

A New Python Language Support In Visual Studio Code

Ambika Choudhury

Recently, Microsoft announced Pylance, which is fast and feature-rich language support for Python in Visual Studio Code. According to a blog post, the name Pylance serves as a bow to Monty Python’s Lancelot, who is known to be the first knight to answer the bridgekeeper’s questions in the Holy Grail.

Two years back, the Python team of the tech giant released the Python Language Server that brought Visual Studio’s rich Python IntelliSense support to Visual Studio Code. The Pylance language server is an enhancement to the Python Language Server. 

Behind Pylance

Pylance is a language server for Python language that utilises the Language Server Protocol in order to communicate with Visual Studio Code. The developers at the tech giant created Pylance as a brand-new language server based on Microsoft’s Pyright static type checking tool in order to deliver an improved user experience.



Pylance provides users with the ability to customise their Python language support through a host of settings that can either be placed in the settings.json file in the workspace or can be edited through the Settings Editor UI.

According to the blog post, the new Pylance extension is complementary to the Python extension for Visual Studio Code. You can easily try the Pylance by downloading the Python extension straight from the Visual Studio Code marketplace.



Features of Pylance

Pylance provides performant language support, and it leverages Microsoft’s open-source static type checking tool, Pyright, in order to provide performant language support for Python language.

Pylance provides several intuitive features for Python 3 that include docstrings, parameter suggestions, code completion, auto-imports, as-you-type reporting of code errors and warnings, code outline, code navigation, code lens, type checking mode, IntelliCode, Jupyter notebook’s compatibility, and multi-root workspace support among others. 

Some of the features of this new language server are mentioned below: –

Optimised Performance

Pylance supercharges the Python IntelliSense experience with rich type information and helps a developer to write better code quickly. The Pylance extension is also dispatched with a cluster of type stubs for modules that provide fast and accurate auto-completion and type checking.

Type Information

Type information is now made available in function signatures. While hovering on symbols, Pylance provides a user with helpful data to assure that the user is correctly invoking functions to improve code quality. 

See Also

Auto-Imports

Auto-Imports is one of the most requested features of Pylance. This feature allows you to get smart import suggestions of installed and standard library modules for autocompletion.

Type Checking Diagnostics

The type checking mode in Pylance can be used by setting python.analysis.typeCheckingMode to basic or strict mode. The setting uses Pyright’s type checking to apply either a basic or comprehensive set of rules over your codebase, respectively. And the diagnostics produced from these modes can help improve the quality of your code and help you find edge cases easily.

Multi-Root Workspace Support

Pylance assists multi-root workspaces in a very naive manner. This means that a user can open more than one folder in the same Visual Studio Code session and also have Pylance functionality in each of the folders.

Wrapping Up

According to the developer of the tech giant, this new Python language support represents a drastic improvement for the Python experience on Visual Studio Code. According to the blog post, the new, free language server offers increased performance and many more features.

Currently, in the short term plan, a user will still be able to use the Microsoft Python Language Server as a choice of language server when writing Python in Visual Studio Code. While in the long term plan, the developers are planning to transition the Microsoft Python Language Server users over to Pylance and eventually deprecate and remove the old language server as a supported option.

Provide your comments below

comments


If you loved this story, do join our Telegram Community.


Also, you can write for us and be one of the 500+ experts who have contributed stories at AIM. Share your nominations here.

Copyright Analytics India Magazine Pvt Ltd

Scroll To Top