Pylance Can Now Run Pyrefly Instead of Pyright. Should You Switch?
For years, using Pylance in VS Code meant using Pyright. Same engine, same opinions about what counts as a type error, whether you liked them or not. If you preferred another checker, you installed a different extension and gave up Pylance's extras. That trade-off just got a lot smaller.
On October 21, Microsoft announced the Type Server Protocol, or TSP, along with a partnership with Meta to bring Pyrefly support into Pylance. I'll explain what changed, show you how to try it in a couple of minutes and say who I think should bother.
What TSP is
Microsoft's Brett Cannon describes TSP as an open standard that extends the Language Server Protocol, the protocol behind editor integrations across the industry. Its purpose is to let any editor or tool plug a type checker in as a first-class backend.
Until now, Pylance and Pyright were tightly coupled. TSP separates them. Pylance becomes the VS Code intelligence layer for Python, and the type checker becomes an interchangeable analysis component underneath it. Pyright stays the default and continues to power the experience for the vast majority of users, Microsoft says. What changes is that you can swap the engine without swapping the editor experience.
Meta's Pyrefly is the first alternative. Microsoft says it worked with Meta to design and implement TSP and to make sure Pyrefly fully supports it. The Pyrefly team's own post says the same, and frames it as a way to choose the checker that fits your codebase without losing the Pylance features you depend on.
What stays the same
Microsoft is explicit about this. Regardless of which checker you use, Pylance still provides completions, Quick Info, environment management and its integration with GitHub Copilot. Those experiences are built on Pylance, not on any one type checker.
That matters because Microsoft's pitch for not simply using Pyrefly's standalone extension is the Copilot side: context for AI completions, code understanding that feeds Copilot Chat, and MCP tools for Python codebases. The company argues a standalone checker extension can't replicate those. If you rely on them, TSP lets you keep them and still use Pyrefly's analysis.
Why anyone would want Pyrefly
Pyrefly is open-source, written in Rust, and checks code very fast. Microsoft puts its speed at 1.8 million lines per second, and the Pyrefly repository says 1.85 million, and claims it type checks projects like PyTorch 15 times faster than Mypy and Pyright. Those are the project's own benchmarks, so treat them as a claim to test, not a promise. The same repository describes the project's status as stable, with a 1.0.0 release.
It also has a real-world endorsement. Google's open source blog said on October 6 that Pyrefly is now the Python type checker at Google, replacing the internal Pytype with significant speedups. Pyrefly's pitch to the rest of us is a consistent experience in CI and in the editor, plus better support for patterns in libraries such as Pydantic and Django, according to the Pyrefly team.
How to switch in VS Code
You need Pylance version 2026.4.1 or newer. Then there are two routes.
Route one: let Pylance suggest it. When you open a workspace, Pylance checks your Python environments for Pyrefly. If it finds it, whether installed in your virtual environment or signalled by a pyrefly.toml file or a [tool.pyrefly] section in pyproject.toml, you'll see a notification asking if you'd like to use Pyrefly as your source of diagnostics. Click Switch to Pyrefly. Cancel dismisses it for the session, and Don't ask again suppresses it for good.
Route two: use the setting. Open VS Code settings and look for Python > Analysis: Diagnostics Source. The Pyrefly team says you can paste vscode://settings/python.analysis.enableExternalTypeServer into a browser to jump to the right setting. There are three options:
- Pylance, the default, uses Pylance's built-in analysis.
- Pylance + Pyright explicitly routes diagnostics through Pyright.
- Pylance + Pyrefly uses Pyrefly as the diagnostics engine.
If you choose the third option, Pylance looks for Pyrefly in your virtual environments or downloads it automatically. A companion setting, Python > Analysis: Pyrefly Version, lets you pin a version, point at a local executable or leave it empty to always use the latest release. The minimum supported Pyrefly version is 0.60.0. Once it's active, the status bar shows the diagnostics source, and clicking it opens the setting.
Should you use this or the Pyrefly extension?
Here's the part I appreciate. The Pyrefly team doesn't tell everyone to use the new integration. They still recommend the standalone Pyrefly VS Code extension for most users, because it gives the most direct Pyrefly experience with the least overhead: diagnostics, completions, go-to-definition, hover and refactoring actions, all powered by Pyrefly's language server with no intermediary.
The Pylance integration is the better choice, they say, if you:
- Rely on GitHub Copilot's integration with Pylance.
- Work on a team that has standardised on Pylance and want to introduce Pyrefly without changing everyone's extensions.
- Want Pylance-specific features, such as its completion ranking, Quick Info or environment management, alongside Pyrefly's type analysis.
My own reading: if you don't use Copilot and you don't care about Pylance's extras, the standalone extension is simpler. If your team is on Pylance and wants to test a faster checker without a tooling debate, this is the low-friction way in.
One caution about differing results
A type checker is an opinion about your code. Pyright and Pyrefly are both strict about different things, and a codebase that is clean under one will usually produce a handful of new messages under the other. That's normal, not a sign something broke. Pyrefly's own docs include guides for migrating from mypy and Pyright, including for Pylance users, so you don't have to guess how its settings map.
A sensible way to test it
- Try it on a branch of a real project, not a toy. The differences show up on large codebases.
- Compare the diagnostics. Two checkers will not agree on everything, particularly around inference. Count the new errors and the errors that disappeared, and read a sample of each.
- Keep CI in mind. If your editor uses Pyrefly and your CI runs Pyright or Mypy, developers will see one set of errors locally and another on the server. Pick one checker for both, or accept the mismatch knowingly.
- Watch performance on your biggest package. If it feels faster, that's a useful result. If it doesn't, you've lost nothing.
- Report problems. Microsoft asks for feedback through issues in the Pylance repository, and the Pyrefly team has a Discord and an issue tracker.
Should you care?
If you write Python in VS Code, mildly yes. Most people should leave the default alone, and Microsoft says Pyright remains the default for a reason. But TSP is the more important story than the switch. An open protocol for type checkers means editors and tools can compete on checker quality without every project needing its own integration. For the Python ecosystem, which has had a fragmented typing story for years, that is an overdue piece of plumbing.
Frequently Asked Questions
What is the Type Server Protocol?
An open standard that extends LSP and lets editors and tools integrate type checkers as first-class backends, announced by Microsoft with Meta.
Which versions do I need?
Pylance 2026.4.1 or newer, and Pyrefly 0.60.0 or newer, per the announcements.
Does switching to Pyrefly remove Pylance's features?
No. Pylance's completions, Quick Info, environment management and Copilot integration stay the same whichever checker you pick.
Is Pyright going away?
No. Microsoft says Pyright remains the default and continues to power the experience for the vast majority of users.
Originally published on Mango Developer.