Pyrefly
Pyrefly is a Rust-written Python type checker and language server. It provides fast CLI type checking and IDE features such as go-to-definition, autocomplete, and code navigation, with built-in Pydantic, Django, and pytest support.
Visit pyrefly-org/pyreflyOverview
Pyrefly is a type checker and language server for Python written in Rust. It combines command-line type checking with editor features such as go-to-definition, autocomplete, hover information, inlay hints, semantic highlighting, and code navigation, with results intended to be consistent across the CLI and editor. It includes built-in support for Pydantic, Django, and pytest and reports adoption at Google, Microsoft Pylance, Instagram, and open source projects including PyTorch and JAX.
Key Features
- Fast type checking: Pyrefly checks over 1.85 million lines of code per second and type checks projects like PyTorch 15x faster than Mypy and Pyright; IDE rechecks typically complete in under 10 milliseconds after saving a file.
- Full-featured language server: go-to-definition, autocomplete, hover, inlay hints, semantic highlighting, and code navigation, with consistent results across the CLI and editor.
- Editor support for VS Code, Neovim, Zed, and more.
- Built-in support for Pydantic, Django, and pytest.
- Experimental tensor shape checking finds shape mismatches in PyTorch code.
- Adoption tooling includes pyrefly init for migration from Mypy or Pyright, pyrefly suppress for silencing existing errors, and pyrefly infer for adding annotations.
Use Cases
- Type checking large Python codebases where type-checking time and editor latency are real costs.
- Providing IDE feedback for Python development through language server features such as go-to-definition, autocomplete, and code navigation.
- Migrating incrementally from Mypy or Pyright by initializing Pyrefly, suppressing existing errors, and adding annotations over time.
- Checking framework-heavy Python projects that use Pydantic, Django, or pytest.
Getting Started
- Try Pyrefly in the browser using the sandbox.
- Install the command-line tool with pip install pyrefly.
- Run pyrefly init in your project to set things up, generate a config, and access migration options from Mypy or Pyright.
- Install the editor extension for VS Code, Neovim, Zed, or another supported editor.
- Use pyrefly suppress to silence existing errors and pyrefly infer to add annotations.
Before You Adopt
- License: MIT. Review its terms before using, modifying, or distributing the project.