Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Pylance Is a New Python Language Server for Visual Studio Code

Pylance Is a New Python Language Server for Visual Studio Code

This item in japanese

Microsoft has announced Pylance, a new language server for Python aimed to help programmers write better Python code and improve IntelliSense and Visual Studio Code support for the language.

Freely available on the Visual Studio Marketplace, Pylance is an implementation of the Language Server Protocol and uses Microsoft’s Pyright static type checking tool to provide rich type information. The extension also includes a number of auto-completion and type checking-enabling stubs for popular modules.

According to Microsoft, Pylance will eventually replace the Microsoft Python Language Server, originally released in 2018. At the moment, Microsoft has no plans to open source it, stated Microsoft program manager Savannah Ostrowski, which rules out Pylance use with third-party editors. This is a bit of a striking decision, which goes:

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.

Besides providing type information in function signatures and when hovering on symbols, Pylance also provides smart-import suggestions for available and standard library modules.

(Image courtesy Microsoft)

As mentioned, Pyright powers Pylance's type checking, which can be run with a basic or comprehensive set of rules over a codebase.

(Image courtesy Microsoft)

You can enable type checking by setting python.analysis.typeCheckingMode to basic or strict. Other useful settings include python.analysis.diagnosticSeverityOverrides, which allows a user to override the severity levels for individual diagnostics, python.analysis.stubPaths, which allows a user to specify a path to a directory that contains custom type stubs, and more.

Pylance supports Visual Studio Code's multi-root workspaces, which means it will work seamlessly on multiple folders opened within the same VSC session.

Other features provided by Pylance include docstrings, parameter suggestions, code outline and navigation, and more.

As a final note, Pylance is compatible with Jupyter Notebooks and supports .pyi, the standard format for packaging and distributing type information.

Rate this Article