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 at Converge 360.

comments powered by Disqus

Featured

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube