Pyrefly: replace mypy with Meta's Rust-powered type checker in one pip install

Pyrefly: replace mypy with Meta's Rust-powered type checker in one pip install

Pyrefly v1.0.0 (Meta, MIT, released May 12 2026) is a Rust-built Python type checker and LSP server that replaces mypy in both CI and the editor with a single pip install. Independent benchmarks show 49× faster than mypy on a 120k-line codebase. The VS Code extension (meta.pyrefly) and PyCharm 2026.1.2 native integration both work out of the box.

VS Code / JetBrains Plugin Pick
2026. 5. 21. · 01:40
구독 1개 · 콘텐츠 6개
If mypy has been the slowest step in your Python CI for a while, the wait for a serious alternative is over. Meta released Pyrefly v1.0.0 on May 12, 2026 1 — a Rust-based Python type checker and language server (LSP) that already runs on Instagram's 20-million-line codebase as the default type checker. 1 One package, one pip install, covers both CI checks and in-editor type inference.

Install

CLI (works with any editor):
pip install pyrefly
# or
uv add --dev pyrefly
Python ≥ 3.8 required. Supports Windows (x86-64, ARM64), Linux (x86-64, ARM64, glibc 2.17+), and macOS (ARM64 11.0+, x86-64 10.12+). 2
VS Code: search Pyrefly in the Extensions panel or install by identifier meta.pyrefly. 3
PyCharm 2026.1.2: open the Type widget at the bottom of the IDE window → select Pyrefly. PyCharm auto-installs it if not present. 4

What it does

Pyrefly is a dual-role tool: run pyrefly check from the terminal for CI batch checking, or let the bundled LSP server power go-to-definition, hover types, and code completion in your editor — both come from the same binary. 1
Type inference goes beyond annotated parameters. Pyrefly infers variable types and return types from unannotated code — def foo(x): return True is inferred as (x: Any) -> bool without any annotation. 1 Flow types track literal values through control flow: x: int = 4 is tracked as Literal[4] at the next usage, narrowing further in conditionals.
Five named presets control how strict the checker is: off, basic (high-confidence errors only — the default for unconfigured projects), legacy (mypy-compatible behavior for gradual migration), default, and strict (no implicit Any). 5
Built-in framework support covers Pydantic (lax mode, range constraints, RootModel, pydantic-settings) and Django (model relationships, fields, views, factory_boy). Jupyter notebooks get full parity with .py files: rename, find references, code actions, document symbols. 1

Usage demo

Migrating from mypy in under a minute:
# 1. Install
pip install pyrefly

# 2. Auto-generate config (detects existing mypy.ini / pyproject.toml / .mypy.ini)
pyrefly init
# → writes [tool.pyrefly] to pyproject.toml, sets preset = "legacy"

# 3. Run
pyrefly check src/
The resulting pyproject.toml block looks like this:
[tool.pyrefly]
project-includes = ["src/**/*"]
preset = "legacy"
Swap preset = "legacy" to preset = "default" when you're ready for stricter checking. 5
Type annotation inference — useful for adding annotations to an untyped codebase:
pyrefly infer src/utils.py
Before:
def total(numbers):
    return sum(numbers)
After (pyrefly infer output):
def total(numbers: list[int]) -> int:
    return sum(numbers)
VS Code setting — force type errors on regardless of project config:
"python.pyrefly.displayTypeErrors": "force-on"

How fast is it?

Independent benchmark data from a public suite that runs daily against 53 popular Python packages 6:
PackagePyrefly v1.0Pyright v1.1.409Mypy v2.1.0
django1.7 s / 292 MB23.1 s / 1,035 MB12.7 s / 409 MB
pandas11.7 s / 756 MBtimeout (>300 s)31.1 s / 586 MB
tensorflow11.6 s / 707 MB211.7 s / 3,951 MB76.6 s / 1,265 MB
flask0.4 s / 186 MB4.1 s / 280 MB3.9 s / 189 MB
Pyrefly did not time out or run out of memory on any of the 53 packages; Pyright timed out on numpy, pandas, and scipy, and OOM-killed on homeassistant and transformers. 6
On a real 120,000-line codebase, one independent test clocked mypy at 9 minutes and Pyrefly at 11 seconds — roughly 49×. 7 A separate April 2026 benchmark on smaller codebases (Rich at 38k LOC, SQLGlot at 74k LOC) found 4–7× faster than mypy. 8 The vendor's headline "76×" derives from Meta's internal Instagram benchmarks; treat it as a plausible ceiling on very large monorepos, not a floor.
For incremental saves in the editor, the improvement is more uniform: PyTorch incremental diagnostics went from 2.4 s to 19 ms on an M4 MacBook Pro — 125× faster. 1

Known limitations


Plugin: Pyrefly · Publisher: Meta Platforms, Inc. · Version: 1.0.0 · License: MIT Language: Python ≥ 3.8 · Use case: Type checking, language server VS Code: meta.pyrefly on VS Code Marketplace · PyPI: pyrefly on PyPI · Source: facebook/pyrefly on GitHub

이 콘텐츠를 둘러싼 관점이나 맥락을 계속 보강해 보세요.

  • 로그인하면 댓글을 작성할 수 있습니다.