News

More Improvements for VS Code's New Python Language Server

Microsoft announced more improvements for the new Python language server for Visual Studio Code, Pylance, specializing in rich type information.

Pylance (named after a Monty Python character) was announced as the new Python language server for VS Code back in June. It uses the Language Server Protocol to communicate with VS Code and boost IntelliSense (which provides intelligent code completion and more) with rich type information, being based on the company's Pyright static type checking tool.

While Pyright is open source, Pylance is not.

"If you are a VS Code user, we recommend that you uninstall Pyright and instead install Pylance," Microsoft says. "You will get all the benefits of Pyright and more!

"Installing both Pyright and Pylance at the same time is not recommended. If both are installed and enabled, you will see duplicate errors, hover text, and completion suggestions."

This graphic shows other differences between the two:

Pyright vs. Pylance
[Click on image for larger view.] Pyright vs. Pylance (source: Microsoft).

"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," said Savannah Ostrowski, program manager for Python and its VS Code language server, at the time. "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."

Working with Python 3, Pylance provides:

  • Docstrings
  • Signature help, with type information
  • Parameter suggestions
  • Code completion
  • Auto-imports (as well as add and remove import code actions)
  • As-you-type reporting of code errors and warnings (diagnostics)
  • Code outline
  • Code navigation
  • Type checking mode
  • Native multi-root workspace support
  • IntelliCode compatibility
  • Jupyter Notebooks compatibility
  • Semantic highlighting

In a new post outlining the improvements to Pylance in the September update to Python in Visual Studio Code (supplied via this extension), Ostrowski detailed new improvements to the tool including:

  • Support for semantic colorization in Pylance: Ostrowski said this extension on syntax highlighting helps improve the readability of code.
    Semantic Colorization in Animated Action
    [Click on image for larger, animated GIF view.] Semantic Colorization Before/After in Animated Action (source: Microsoft).
  • Pylance auto-import improvements: "With improved auto-import completions, you can now see a clearer preview of the import statement that will be added to your file in the completion tooltip. The way that Pylance adds imports to your file has also been improved by detecting when you've already imported other submodules or functions from that module. Instead of adding a duplicate import statement to your file, Pylance will now amend the existing one by adding the symbol alphabetically in the statement, helping to keep your imports organized."
    Auto-Import Improvements in Animated Action
    [Click on image for larger, animated GIF view.] Auto-Import Improvements in Animated Action (source: Microsoft).

The update also includes many other minor improvements, as explained in the Sept. 23 post and changelog, which lists eight such minor enhancements as well as more than 20 fixes.

Pylance is listed as still being in the preview stage in the VS Code Marketplace, where it shows more than 166,000 installations and has earned an average 3.9 rating (0-5 scale) from 33 developers who reviewed it.

The Python extension for VS Code, meanwhile, is by far the most popular tool in the marketplace, being installed more than 25 million times.

About the Author

David Ramel is an editor and writer for Converge360.

comments powered by Disqus

Featured

  • Creating Reactive Applications in .NET

    In modern applications, data is being retrieved in asynchronous, real-time streams, as traditional pull requests where the clients asks for data from the server are becoming a thing of the past.

  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

Subscribe on YouTube