Now, let’s talk about the new kid on the block who showed up with a trust fund and a surprisingly sharp intellect: Pyright. This is Microsoft’s open-source type checker, and its closed-source, deeply integrated sibling for VS Code is called Pylance. Don’t get them confused: Pyright is the standalone engine you can run from the command line, and Pylance is the VS Code extension that uses Pyright’s brain but also adds incredible IntelliSense, auto-imports, and other editor magic that will make you weep with joy.

I know what you’re thinking: “Microsoft? For Python?” Trust me, I had the same skeptical eyebrow raise. But here’s the thing: they built something genuinely brilliant. Pyright is fast. Blisteringly, “wait-is-it-even-done-yet?” fast. It’s written in TypeScript and runs on Node.js, which is a bizarre choice for a Python tool that somehow, infuriatingly, works incredibly well. This architecture lets it perform deep analysis without you feeling like you’re waiting for a binary to compile. It’s often significantly quicker than mypy, especially on larger codebases, and its error messages are frequently clearer and more actionable.

Performance and Architecture: The Node.js Elephant in the Room

Yes, it needs Node.js. No, it doesn’t make a lick of sense until you realize that the V8 engine is a beast and the TypeScript compiler team really knows how to build a responsive language server. This isn’t a script kicking around .py files; it’s a full-fledged Language Server Protocol (LSP) implementation. This is why Pylance feels so seamless in VS Code—it’s speaking the editor’s native tongue. You can run the standalone pyright CLI easily enough:

npm install -g pyright  # The weird part
pyright my_project/     # The awesome part

Strictness and The pyrightconfig.json File

Out of the box, Pyright is generally more permissive than mypy under its strictest settings. But don’t mistake its pleasant default demeanor for weakness. You can unleash its full pedantic power through a pyrightconfig.json file. This is where you move from “friendly suggestions” to “hard requirements.” Let’s say you want to ban any use of Any and ensure every function has a return type. Your config file would look like this:

{
  "reportGeneralTypeIssues": "error",
  "reportMissingImports": "error",
  "reportOptionalSubscript": "error",
  "reportOptionalMemberAccess": "error",
  "reportOptionalCall": "error",
  "reportPrivateImportUsage": "error",
  "reportUnusedImport": "error",
  "reportUnusedVariable": "error",
  "reportUnknownMemberType": "error",
  "reportUnknownArgumentType": "error",
  "reportUnknownVariableType": "error",
  "reportMissingTypeStubs": "warning"
}

Suddenly, Pyright becomes the sternest schoolmaster you’ve ever met. It’s fantastic.

Beyond Mypy: Smarter Inference and Unique Features

Pyright isn’t just a faster mypy clone; it’s often smarter. It has superior type narrowing capabilities. Check this out:

def some_risky_operation(value: str | None) -> int:
    if value is None:
        return 0
    # Pyright knows that here, `value` is absolutely a str.
    # Mypy knows this too, but Pyright is more consistent in complex scenarios.
    return len(value)

Where it really pulls ahead is with its support for recursive type aliases and type guards. Mypy famously struggles with the former. Pyright handles them with ease:

from typing import TypeAlias, Union

# Trying this in mypy requires a mypy plugin. Pyright just gets it.
JsonValue: TypeAlias = Union[None, bool, str, int, list['JsonValue'], dict[str, 'JsonValue']]

data: JsonValue = {"key": [1, 2, None, {"nested": "value"}]}

Pylance: The Editor Supercharger

This is where the magic becomes palpable. Pylance isn’t just type checking; it’s a full-featured language server. The moment you install it in VS Code, your editing experience changes. Auto-completion becomes scarily intelligent, offering relevant suggestions based on profound type analysis, not just dumb string matching. It handles auto-imports better than any other Python extension. It provides quick fixes for common type errors. It’s the single biggest productivity boost for a Python developer in the last five years, and I will die on that hill.

The Rough Edges and The Bottom Line

It’s not all perfect. Being Microsoft’s darling, the VS Code experience is first-class, but support in other editors (Neovim, Emacs, etc.) via the LSP, while good, can sometimes feel a half-step behind. The configuration is also different from mypy’s mypy.ini, so there’s a slight learning curve.

So, which should you use? Honestly, for new projects, I almost always recommend starting with Pyright/Pylance. The speed and developer experience are just too good to ignore. For existing projects deeply tied to mypy’s specific ruleset, a migration might take some work. The best part? You don’t always have to choose. You can run both on your CI pipeline to catch the unique edge cases each one finds. It’s overkill for most, but for a critical codebase, it’s the ultimate flex.