Skip to content
audiotale.net
Sign in
NewsNews

Pylance now runs Pyrefly: Type Server Protocol 0.4.1 explained, and how to switch in VS Code

Microsoft and Meta announced the Type Server Protocol on 21 October 2026, letting VS Code's Pylance use Pyrefly instead of Pyright; here is how it works and how to enable it.

audiotale.net team

· 6 min read

Written by AI from the sources linked below. How we use AI

On this page
  1. Key points
  2. What to do
  3. What happened
  4. Background
  5. How it works
  6. What it means
  7. What we don't know yet
  8. What to watch next
  9. Sources

Microsoft has published the Type Server Protocol (TSP), an open protocol that lets the Pylance language server in VS Code ask any compatible type checker for Python type information, and with it Pylance can now use Meta's Pyrefly instead of Pyright. Announced on 21 October 2026, the change ends a long-standing coupling: Pylance has been built on Pyright since it launched in 2020, and until now a developer who preferred another checker had to give up Pylance's features or run a second extension.

Key points

  • TSP is a JSON-RPC protocol that extends the Language Server Protocol; its methods are prefixed typeServer/, and the specification is at version 0.4.1 in Microsoft's pylance-release repository.
  • Microsoft says it co-designed TSP with Meta, and that Meta made Pyrefly support it fully.
  • Pyright stays the default checker; Pylance with Pyrefly is an opt-in choice.
  • It needs Pylance 2026.4.1 or newer and Pyrefly 0.60.0 or newer (Microsoft).
  • Pyrefly's own team still recommends its standalone extension for most people, because it has the least overhead.

What to do

If you use VS Code for Python and want to try Pyrefly with Pylance:

  1. Update the Python extension so you have Pylance 2026.4.1 or newer, and install Pyrefly 0.60.0 or newer in your environment (or let Pylance use the version it finds).
  2. If Pylance detects Pyrefly in the environment, or a pyrefly.toml or a [tool.pyrefly] section in pyproject.toml, it offers to switch. The Pyrefly team says the choices are Switch to Pyrefly, Cancel and Don't ask again.
  3. To switch manually, set Python › Analysis: Diagnostics Source to one of three values: Pylance (the default), Pylance + Pyright, or Pylance + Pyrefly. The status bar then shows the active diagnostics source.
  4. To pin a checker version, set Python › Analysis: Pyrefly Version to a version, a path to a local executable, or leave it empty for the latest release.

To go back, change the same setting. If you do nothing, nothing changes: Pyright remains the default and, in Microsoft's words, continues to power the experience for most users.

What happened

Microsoft's Python team announced TSP together with a partnership with Meta, which develops Pyrefly. The announcement describes TSP as an open standard that extends LSP so an editor can plug in a type checker as a backend. In this model Pylance becomes the IDE intelligence layer, and the type checker underneath it becomes a swappable component.

What stays the same when you switch checkers, according to Microsoft, is the part of Pylance that is not type checking: completions, Quick Info (hover information), environment management and the GitHub Copilot integration. Microsoft also argues for using Pyrefly through Pylance rather than on its own: Pylance adds Copilot-related features such as context for AI completions, code understanding for Copilot Chat and MCP tools for Python codebases, which a standalone extension does not provide.

Meta's side of the story is more measured. Pyrefly's team says the integration ends the trade-off created because "Pylance has been tightly coupled to Pyright", but it still recommends its standalone extension for most users because there is no intermediary. It suggests the Pylance route if you use Copilot with Pylance, your team has standardised on Pylance, or you want Pylance features such as smart completion ranking.

Microsoft's post also cites a speed figure for Pyrefly of 1.8 million lines of code per second; that is Microsoft's number, repeated in its own announcement, and we have not seen an independent benchmark, so treat it as a vendor claim.

Background

Pylance launched in 2020 as a language server for VS Code built on Pyright, Microsoft's static type checker for Python. That gave Python users fast type analysis, but it also tied the editor experience to one checker's behaviour. Python's type-checking ecosystem has since grown: Pyright, mypy and newer tools written in Rust and other fast languages all interpret the typing rules slightly differently, and teams often enforce one of them in continuous integration. A mismatch between the checker in the editor and the checker in CI produces errors that appear in one place and not the other.

The usual workaround was to install a checker's own extension next to Pylance, with diagnostics and hover information from two sources. TSP is meant to remove that duplication by giving the editor layer one defined way to ask a type server what it knows.

How it works

The TSP specification, hosted in Microsoft's pylance-release repository, defines it as a JSON-RPC protocol for asking a type server for Python analysis data. It reuses LSP data shapes such as Position and Range. The client starts the type server and talks to it over the main connection, using standard input and output or Node IPC.

The startup sequence is the standard LSP initialize and initialized exchange, then typeServer/getSupportedProtocolVersion to check compatibility, then typeServer/getSnapshot to get an initial snapshot ID. Every query carries that snapshot ID. When earlier results may no longer be valid, for example after a file edit, the server sends typeServer/snapshotChanged. Snapshot IDs are non-negative integers that never decrease, and a request for a stale snapshot should fail with error code -32802 (ServerCancelled), so the client fetches a fresh snapshot and retries.

The specification lists these messages:

Message Direction Returns
getSupportedProtocolVersion client to server version string
getSnapshot client to server snapshot number
snapshotChanged server to client notification with old and new IDs
getPythonSearchPaths client to server search paths
resolveImport client to server resolved path
getComputedType client to server type
getDeclaredType client to server type
getExpectedType client to server type

The three type queries differ in what they report. The computed type is the one inferred from code flow, the declared type is what the source annotates, and the expected type is the type the surrounding context requires. Results are tagged objects with a numeric kind from 0 to 9 (for example function, class, union or module), and the IDs inside a response are only meaningful within that response.

The 0.x version line means minor versions may include breaking changes. Version 0.4.1 added an optional multi-connection mode, advertised through capabilities.experimental.typeServerMultiConnection, which lets a client open extra read-only channels for concurrent work; the specification says servers must work without it.

What it means

For Python developers. The practical gain is choice without losing the editor features: you can run the checker your CI uses, or one that is faster on a very large codebase, while keeping Pylance's Copilot features. If your project runs Pyright in CI, there is no reason to change.

For tool authors. TSP gives other type checkers a documented path into VS Code's Python experience, although the specification itself does not name any implementers beyond what Microsoft's announcement describes.

For Meta and Microsoft. Pyrefly gets exposure inside the most widely used Python editor, and Microsoft keeps the Copilot integration as the reason to stay on Pylance. Both vendors benefit, which is worth keeping in mind when reading their claims about each other's products.

What we don't know yet

  • Other checkers. The specification does not say whether mypy or other tools will implement TSP.
  • Independent performance data. We found no independent comparison of Pylance with Pyright against Pylance with Pyrefly.
  • Exact availability. One Taiwanese outlet reported that the option is open to all VS Code users; we could not open that report, and Microsoft's post names only the version requirements above.
  • Stability. The 0.x version number and the experimental multi-connection capability mean the protocol can still change.

What to watch next

Watch the pylance-release repository for new TSP versions and for any move from 0.x to a stable 1.0, and for announcements from other type checkers about implementing the protocol. If you maintain a Python project, check whether a diagnostics difference between your editor and your CI checker shows up after you switch.

Sources

Written by

audiotale.net team

The official account of the people who run audiotale.net: announcements, conversation starters and the newsroom's drafts. Posts written with AI say so. Every other account here is a real person.