Pyrefly is a static type checker for Python that operates as a language server, delivering real-time diagnostics, completions, and navigation in any editor supporting the Language Server Protocol. It also performs static tensor shape analysis, using symbolic dimension variables and arithmetic to verify shape consistency in deep learning models without runtime execution.
Beyond core type checking, Pyrefly supports gradual adoption workflows: it can generate a baseline of known errors so only new issues are reported, migrate configuration from other type checkers, and automatically suppress existing errors. Preset-based strictness tiers—safe, strict, and custom—control the level of checking. The checker natively understands Django ORM models, class-based views, and Pydantic models, inferring types without plugins. It integrates with CI pipelines through pre-commit hooks and inline error annotations on pull requests.
Pyrefly’s incremental architecture re-checks only modified files, providing sub-second feedback. Import resolution prefers stub files over source code and bundles type stubs for popular libraries. The language server offers autocomplete, hover information, inlay hints, signature help, code actions, and navigation features such as go-to-definition, find all references, call and type hierarchies, and workspace symbol search. Diagnostics appear in notebooks and with semantic token highlighting.
Configuration is handled through project files with options for import resolution, typeshed paths, and types of errors to report. The checker measures type coverage and can report per-module statistics.