ScriptsMay 25, 2026·3 min read

Pyre — Fast Type Checker for Python by Meta

Pyre is a performant, static type checker for Python developed at Meta, designed to catch type errors in large codebases with minimal configuration and fast incremental analysis.

Agent ready

This asset can be read and installed directly by agents

TokRepo exposes a universal CLI command, install contract, metadata JSON, adapter-aware plan, and raw content links so agents can judge fit, risk, and next actions.

Native · 98/100Policy: allow
Agent surface
Any MCP/CLI agent
Kind
Skill
Install
Single
Trust
Trust: Established
Entrypoint
Pyre Overview
Universal CLI install command
npx tokrepo install 8bc4ba20-5837-11f1-9bc6-00163e2b0d79

Introduction

Pyre is a static type checker for Python that analyzes type annotations to catch bugs before runtime. Built by Meta for internal use on millions of lines of Python code, it prioritizes speed and incremental analysis so developers get fast feedback without disrupting their workflow.

What Pyre Does

  • Checks Python type annotations against PEP 484, 526, 544, and later typing PEPs
  • Runs in incremental watch mode with sub-second feedback on file saves
  • Infers return types and variable types where annotations are missing
  • Integrates with editors via the Language Server Protocol
  • Includes Pysa, a taint analysis tool for finding security vulnerabilities

Architecture Overview

Pyre is implemented in OCaml for performance. It parses Python source files into an internal AST, resolves imports and builds a module dependency graph, then runs constraint-based type inference and checking in parallel. In watch mode, it uses a file-system watcher to re-analyze only changed files and their dependents, keeping incremental checks fast even in large repos.

Self-Hosting & Configuration

  • Install via pip: pip install pyre-check
  • Initialize with pyre init to create a .pyre_configuration file
  • Set source_directories and search_path to control what gets checked
  • Use strict mode for stricter checking or unsafe to suppress specific errors
  • Configure per-file overrides with inline # pyre-strict or # pyre-ignore comments

Key Features

  • Sub-second incremental checks in watch mode for instant feedback
  • OCaml implementation delivers multi-threaded parallel analysis
  • Pysa security analyzer detects taint flows (SQL injection, XSS, etc.) using the same type infrastructure
  • LSP support provides hover types, go-to-definition, and autocomplete in editors
  • Gradual typing lets teams adopt type checking incrementally, file by file

Comparison with Similar Tools

  • mypy — The reference Python type checker; Pyre is faster on large codebases but mypy has broader community plugin support
  • Pyright — Microsoft TypeScript-based checker powering Pylance; fast and well-integrated with VS Code
  • Pytype — Google type checker with cross-function inference; slower but infers more without annotations
  • Ruff — Linter and formatter, not a type checker; complementary to Pyre

FAQ

Q: Can I use Pyre alongside mypy? A: Yes. Both read the same PEP 484 type annotations. You can run both and compare results during migration.

Q: What is Pysa? A: Pysa is Pyre's taint analysis engine that tracks untrusted data through function calls to detect security vulnerabilities like SQL injection.

Q: Does Pyre support Python 3.12+ syntax? A: Pyre tracks CPython releases. Check the changelog for the latest supported Python version.

Q: How does Pyre handle third-party libraries without type stubs? A: Pyre uses typeshed stubs and can fall back to Any for untyped libraries. You can also add custom stubs.

Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets