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

Savannah Ostrowski

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.

21 comments

Discussion is closed. Login to edit/delete existing comments.

  • David Rinck 0

    Bravo!! I love the improvements.

  • Ian MacLean 0

    Looks great. I will switch to it and give it a try. Question though – the announcement calls it “The new, free language server ” and there is no mention of open-sourcing in the “Future” section. Given the recent trajectory of MS developer-related projects recently – is the plan to align with that and open source pylance ? The github link seems a touch disingenuous – since the project contains only the release notes documentation – and already has an issue logged – asking exactly this question https://github.com/microsoft/pylance-release/issues/4 . This looks like a fantastic piece of software – but better to be upfront and transparent with the messaging – whatever the future direction will be.

    • Savannah OstrowskiMicrosoft employee 0

      Thank you for the feedback. We have clarified in the GitHub issue that you linked that we are not planning on open-sourcing Pylance. We want to be transparent about that. The future section in the blog post was referring to users of an older version of our language server.

      • Rafal Chlodnicki 0

        Interesting decision…

        The spirit of LSP is to enable language features across various editors so that seems a bit backward.

        Not sure what stops you from open-sourcing it but maybe releasing the server in “binary” form would make it possible? Not that “binary” is a thing in JS world but if the code is minified and obfuscated then that could count as binary, I guess.

      • Ian MacLean 0

        thanks for replying. And appreciate the update on the project description to clarify the OSS status.

  • Carmichael, George 0

    Looks great! Installed 🙂

  • Erick Ricardo Mendonça Santos 0

    This looks awesome. I’m trying it now!

  • Jason K Bellew 0

    Time for the silly question….does this or can this replace pylint or mypy?

  • Adam Machanic 0

    This looks very cool! Can you comment on how — or whether — it plays with the IntelliCode extension? I’ve been using that for some time now and it really improves the VS Code Python experience. Should I uninstall that if I’m using this, or..?

    Thanks!

    • Savannah OstrowskiMicrosoft employee 0

      Hey Adam! Thanks for the kind words!

      Pylance is completely compatible with IntelliCode! You should install the Pylance extension alongside the IntelliCode extension.

      • Adam Machanic 0

        Thanks for the reply. I tried it out and it worked mostly great, but I hit an issue where half of the code in one of my modules was grayed out and marked as “inaccessible.” I’m certainly looking forward to a more stable experience, but aside from that hiccup it seems to be a huge upgrade.

        • Savannah OstrowskiMicrosoft employee 0

          Hey Adam. Would you mind filing an issue on our repo ? I’d love to get some additional details around the issue your running into and see if we can figure out what’s going on.

      • Or Chen 0

        Hey,

        I have Pylance and IntelliCode, but IntelliCode extension requires to activate Microsoft Python Language Server
        and Pylance needs to enable its own language server…
        I am wondering how they can work together?

        Thanks!

  • Fawad Raza 0

    Too new for me to switch.
    But will star and keep and watch on GitHub. Perhaps switch in a year’s time.

  • milgerd sade 0

    I use this site python https://www.asroon.ir/

    • Rov McGlynn 0

      really? how check the site is pyhton or no?

    • ismaeil sahab 0

      really? how check the site is pyhton or no? https://ismaeilsahab.ir/

  • Fahrer Feyton Fabruce 0

    I have switched to pylance today, but as I was using pycodestyle for formatting and I have sort Imports on save set to True. My imports are being deleted on formatting.
    I had to turn off sort Imports on save in order to tackle the problem, but all around this server is very good.

  • Emin Buğra Saral 0

    Thanks for the long waited extension! But auto importing feature is not working, whatever I tried. 🙁

Feedback usabilla icon