We’re excited to announce that Pylance, our fast and feature-rich language support for Python in Visual Studio Code, is now officially out of preview and has reached its first stable release.
Join us on Learn TV today (May 13, 2021) for a livestream event at 12:00pm PST to help us celebrate the launch and for an overview of the most performant and user-friendly editing experience for Python in VS Code ever.
Earlier this week, we announced that as of the May release of the Python extension, Pylance is also now the default Python language server in Visual Studio Code. Pylance is also now included in the Python core extension’s bundle as an optional dependency, meaning that we’ll automatically install it for you, but you have the option to use another language server of your choice.
Background
Last June, we released a public preview of a new Python language server, Pylance, as a commitment to providing robust and performant language features to Python users in Visual Studio Code. Since Pylance’s public preview, we’ve received both praise and constructive feedback from the community which we have used to guide our work over the last eleven months.
Today, we are pleased to announce that the core Pylance feature set has reached its stable release in Visual Studio Code!
Overview of Pylance features
Since our initial release, we’ve continued to improve the performance and experience of several key features (e.g., completions, auto-imports, function signature help, docstrings), and added new features (e.g., extract variable and extract method code actions, contextual highlighting).
If you aren’t already a Pylance user, here’s a quick overview of some of the rich features that the language server provides for Python development in Visual Studio Code.
Auto-import completions
With auto-imports, you can get smart import suggestions in your completions list for installed and standard library modules. Upon selection, the appropriate import will be added to the top of your file, so you don’t have to scroll to the top and add it in manually. Auto-import completions also include a clear preview of the import statement that will be added to your file in the completion tooltip so you know exactly what symbol you are importing. If you have already imported other submodules or functions from that module, Pylance will amend the existing statement by adding the new symbol alphabetically, helping to keep your imports organized.
Function signature help with parameter and return type information
Pylance provides a useful function signature tooltip which includes type information to help you properly invoke functions without needing to look at external documentation. Function signature help also handles functions with multiple overrides. You can navigate between signatures easily while Pylance bolds the appropriate active parameter.
Code navigation
Pylance also provides performant code navigation functionality, like go to definition and go to declaration, to allow you to quickly jump to user-defined code, source files (e.g. .py) or type stub files (.pyi).
Refactoring code actions – extract variable and extract method
Pylance also provides you to use refactoring code actions which allows you to highlight lines of code and automatically refactor and extract them into new methods or variables at the click of a button!
Extract Variable
Extract Method
Semantic colorization
Pylance’s semantic colorization helps improve the readability and understanding of your code. If you are unfamiliar with semantic colorization, it’s an extension on syntax highlighting. Pylance generates semantic tokens which are used by themes to apply colors based on the semantic meaning of symbols (e.g., variables, functions, modules all have distinct colors applied to them).
To see this new feature in action, you will need to apply a theme that supports semantic color. Some great themes to try out semantic colorization are the built-in Dark+ theme or One Dark Pro used below.
Contextual document highlighting
Pylance supports contextual highlighting, which helps you quickly identify where symbols are used in a particular file.
Type checking support via Pyright
Because Pylance leverages our open-source type checker called Pyright, the language server also comes with a built-in, static type checker if you are interested in writing typed Python. By default, no type checking functionality is enabled, and you’ll only see diagnostics (errors and warnings) in your code when you have syntactically invalid Python. However, you can enable basic or strict type checking by configuring python.analysis.typeCheckingMode. 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.
IntelliCode compatibility
Pylance is also fully compatible with IntelliCode, which brings recommended completions for your specific code context to the top of your completions list to further enhance your productivity!
Feedback
If you have any questions, comments, or feedback on your experience, please reach out to us on GitHub.
Thanks Savannah. Would you know if VScode has an easy way to: add jupyter-style sections to a .py file and then convert the .py file to ipynb?
I found a way to export to Jupyter using the interactive window. But that would require me to run each .py file, which I’m keen to avoid.