Pyrefly: Python Type Checker by Meta
Pyrefly is a static type checker and language server for Python, developed by Meta. It performs static analysis on Python code to identify type-related issues before runtime and provides IDE features like code navigation, autocompletion, and semantic highlighting.
Pyrefly is a clean-slate implementation inspired by Meta’s earlier Pyre type checker. It uses a new type inference engine, a custom incremental computation model, and multi-threaded parallel checking.
When to use Pyrefly
Pyrefly is worth evaluating for large Python codebases where mypy or pyright feel slow and where aggressive type inference that catches errors in unannotated code is desirable. Its conformance score (90% of the typing spec test suite as of April 2026, per the Python typing conformance dashboard) is higher than mypy and ty, though lower than pyright and Zuban (another Rust-based checker).
Pyrefly is in beta. Active development, missing features, and breaking changes between releases are expected. For a comparison of all major type checkers, see How do mypy, pyright, and ty compare?.
Key Features
- Performance: checks over 1.85 million lines of code per second. Meta reports checking Instagram’s 20-million-line codebase in roughly 30 seconds.
- Aggressive type inference: infers types of variables and return types without annotations. Unlike ty’s gradual guarantee approach, Pyrefly reveals concrete unions and catches errors like
None * 2even in unannotated code. - Flow types: refines static types through control flow analysis, narrowing types after guards and checks.
- Auto-annotation tool:
pyrefly infer(formerlyautotype) writes type annotations directly into source files for parameters, return types, container element types, and the imports they require. See how to add type annotations with pyrefly infer. - Module-level incrementality: rechecks only modules that changed, with optimized parallel checking across available cores.
- Language server: full LSP implementation with code navigation, semantic highlighting, code completion, and inline documentation.
- Typing spec conformance: Pyrefly 0.62 passes 90% of the official Python typing conformance test suite (126/140 test files) as of April 2026, ahead of mypy and ty, behind pyright and Zuban.
Pros
- Faster than mypy and pyright by 10-50x on large codebases
- Higher typing spec conformance than mypy and ty
- Aggressive inference catches bugs in unannotated code without requiring explicit annotations
- Cross-platform: macOS, Linux, and Windows (including ARM64)
- MIT licensed
Cons
- Beta status: active development, missing features, and breaking changes between releases are expected
Installation and Usage
# Install with pip or uv
pip install pyrefly
uv pip install pyrefly
# Initialize configuration
pyrefly init
# Check a project
pyrefly check
# Run without installing
uvx pyrefly checkPyrefly reads configuration from either [tool.pyrefly] in your project’s pyproject.toml or a standalone pyrefly.toml file. pyrefly init generates a starter config.
To add Pyrefly as a development dependency in a uv project:
uv add --dev pyrefly
uv run pyrefly checkTo bootstrap annotations on an existing codebase, pyrefly infer writes annotations into source files using static analysis:
uv run pyrefly infer src/See how to add type annotations with pyrefly infer for the full workflow.
Editor Integration
- VS Code: install the Pyrefly extension from the VS Code Marketplace.
- Neovim: supported through LSP configuration.
- Zed: supported through built-in LSP integration.
For other editors, Pyrefly’s language server speaks LSP and can be used with any compatible client.
Comparison to Other Tools
Pyrefly occupies a distinct position among Python type checkers. It infers types more aggressively than ty (which follows a gradual guarantee that never adds errors to working code) but has lower conformance than pyright and Zuban on the official conformance suite. Pyrefly and ty are competitive on raw speed; specific benchmarks shift release to release as both tools optimize.