Microsoft has released Pylance, a new language server for Python that helps programmers write better Python code and improve IntelliSense and Visual Studio Code support for those languages.
Free from the Visual Studio Marketplace, Pylance is an implementation of the language server protocol and uses Microsoft’s Pyright static type checking tool to provide various types of information. In addition, this extension includes several auto-complete and type-checkable stubs for popular modules.
According to Microsoft, Pylance will replace Microsoft Python Language Server, which was first released in 2018. Currently, Microsoft hasn’t planned on open source, said Microsoft program manager Savannah Ostrowski, excluding Pylance from using it with third-party editors. This is a little surprising decision.
Pylance has greatly improved the Python experience in Visual Studio Code, and the team has been working for months. The new free language server offers improved performance and more features. Because of this, the team’s focus shifts to Pylance to continue to evolve.
Pylance provides type information to the function signature, is available when hovering over symbols, and offers smart import suggestions for standard library modules.
As mentioned earlier, Pyright enhances Pylance’s type checking capabilities, allowing you to run it as a basic or comprehensive set of rules for your codebase.
Alternatively, you can enable type checking by setting it to python.analysis.typeCheckingMode. Other useful settings include a .typestrictpython.analysis.diagnosticSeverityOverridespython.analysis.stubPaths that allows users to specify custom directory stubs and specify directory paths, allowing users to override individual diagnostic severity levels.
Pylance supports multiple root workspaces in Visual Studio Code, so it works seamlessly across multiple folders opened in the same VSC session.
Other features provided by Pylance include docstrings, parameter suggestions, code overviews and navigation.
Finally, Pylance is compatible with Jupyter Notebook and supports .pyi, a standard format for packaging and distributing format information.