# 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. ## Install Save as a script file and run: # Pyre — Fast Type Checker for Python by Meta ## Quick Use ```bash pip install pyre-check cd my_project pyre init # creates .pyre_configuration pyre check # type-check the entire project pyre --watch # incremental mode for development ``` ## 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 - https://github.com/facebook/pyre-check - https://pyre-check.org/ --- Source: https://tokrepo.com/en/workflows/asset-8bc4ba20 Author: Script Depot