Announcing Pylance: Fast, feature-rich language support for Python in Visual Studio Code

Savannah Ostrowski

Savannah

We are excited to announce Pylance, our fast and feature-rich language support for Python! Pylance is available today in the Visual Studio Code marketplace.

Pylance depends on our core Python extension and builds upon that experience, for those of you who have already installed it.

Optimized performance

Pylance is a new language server for Python, which uses the Language Server Protocol to communicate with VS Code.

The name Pylance serves as a nod to Monty Python’s Lancelot, who is the first knight to answer the bridgekeeper’s questions in the Holy Grail.

To deliver an improved user experience, we’ve created Pylance as a brand-new language server based on Microsoft’s Pyright static type checking tool. Pylance leverages type stubs (.pyi files) and lazy type inferencing to provide a highly-performant development experience. Pylance supercharges your Python IntelliSense experience with rich type information, helping you write better code, faster. The Pylance extension is also shipped with a collection of type stubs for popular modules to provide fast and accurate auto-completions and type checking.

In 2018, the Python team at Microsoft released the Python Language Server, bringing Visual Studio’s rich Python IntelliSense support to Visual Studio Code. Since our initial release, the Python community has provided us with invaluable feedback about how we can make the user experience of our Python Language Server even better. Over the past several months, we have evaluated how we can make the language server more performant and empower you to write your best code.

Today, we are happy to announce the outcome of this work as the new Pylance language server.

Alongside its performance, there are a few great features that Pylance offers.

 

Type Information

Type information is now available in function signatures and when hovering on symbols, providing you with helpful information to ensure that you are correctly invoking functions, to improve the quality of the code you write.

Image type information

 

Auto-Imports

One of our most requested features is finally here! With auto-imports, you are now able to get smart import suggestions in your completions list for installed and standard library modules.

Image auto imports

 

Type Checking Diagnostics

If you are excited about types in Python, you can try out Pylance’s type checking mode by setting python.analysis.typeCheckingMode to basic or strict. This setting uses Pyright’s type checking to apply either a basic or comprehensive set of rules over your codebase, respectively. The diagnostics produced from this mode can help improve the quality of your code and help you find edge cases more easily.

Image typecheckingmode setting final

 

Multi-Root Workspace Support

Pylance natively supports multi-root workspaces, meaning that you can open multiple folders in the same Visual Studio Code session and have Pylance functionality in each folder.

Image multiroot final

 

Using the Pylance Language Server with the Python Extension

The new Pylance extension is complementary to the Python extension for VS Code that you know and love. If you have the Python extension installed, you can try out Pylance by downloading the extension straight from the Visual Studio Code marketplace. Upon installation, the Python extension will recognize that you’ve installed Pylance and prompt you to select it as your language server. If you are not already using the Python extension in VS Code, installing Pylance will fetch that extension as well.

Image download smaller

 

Note: If you are a Pyright extension user in VS Code, you’ll want to uninstall Pyright when installing Pylance. All Pyright functionality is included in Pylance. By having both extensions installed, you may encounter installation conflicts and see duplicative diagnostics (e.g., errors, warnings) surface in your code.

The future of the Microsoft Python Language Server

Pylance represents a drastic improvement for the Python experience in Visual Studio Code, to which our team has dedicated months of work. The new, free language server offers increased performance and many more features. Because of that, our team’s focus will shift to Pylance to continue evolving it.

In the short-term, you will still be able to use the Microsoft Python Language Server as your choice of language server when writing Python in Visual Studio Code.

Our long-term plan is to transition our Microsoft Python Language Server users over to Pylance and eventually deprecate and remove the old language server as a supported option.

 

Feedback

If you have any questions, comments, or feedback on your experience, please reach out to us on GitHub.

9 comments

Leave a comment