Microsoft is adding better support for Python in VS Code with the introduction of Pylance. Pylance builds on the experience of the Python Language Service, which was added to VS Code two years ago.
Continuing the language’s reference to Monty Python, Pylance is named for Monty Python’s Lancelot, Microsoft explained. Pylance includes a number of useful features, including type information, auto-imports, type checking diagnostics, and multi-root workspace support.
“Pylance supercharges your Python IntelliSense experience with rich type information, helping you write better code, faster,” Savannah Ostrowski, program manager of the Python Language Server and Python in Visual Studio, wrote in a post.
Type information is provided in function signatures and when hovering over symbols. This helps developers ensure that they are correctly invoking functions.
Another feature of Pylance is auto-imports. According to Microsoft, this was a highly requested feature. Auto-imports provide smart suggestions when typing code based on installed and standard library modules.
Pylance also has a type checking mode that can be used to apply a set of rules over a codebase. It then provides diagnostics that can be used to improve code quality and find edge cases.
Multi-root workspaces are also natively supported, allowing developers to open multiple folders in a VS Code session and have Pylance functionality in each of them.
Pylance is offered as an extension to the Python extension for VS Code. Those who already have the Python extension installed can start using Pylance by downloading its extension from the Visual Studio Code marketplace.
Going forward, Microsoft plans on shifting a lot of its focus into evolving Pylance, as it believes Pylance represents a major improvement to the Python experience in VS Code. For now, developers can still use the Microsoft Python Language Server when writing Python code in VS Code, but the company does plan to transition those users over to Pylance. Microsoft will eventually deprecate and remove the Python Language Server as an option.