Pyrefly

0.60.2 · active · verified Fri Apr 10

Pyrefly is a fast type checker and language server for Python, developed by Meta and written in Rust. It provides lightning-fast static type checking along with powerful IDE features such as code navigation, semantic highlighting, and code completion. Pyrefly aims to catch type-related errors before runtime, improve code quality, and enhance the developer experience. It is available as a command-line tool and an IDE extension, with new releases typically every Monday and more frequent updates for new features and bug fixes.

Warnings

Install

Quickstart

This quickstart demonstrates how to install Pyrefly, initialize a project, and run a basic type check on a Python file containing a simple type error. Pyrefly operates as a command-line tool, not typically imported within Python code.

# 1. Create a new project directory and navigate into it
# mkdir my_project && cd my_project

# 2. Install Pyrefly (assuming pip is installed and virtual environment is active)
# pip install pyrefly

# 3. Initialize Pyrefly configuration (creates pyproject.toml or pyrefly.toml)
# pyrefly init

# 4. Create a sample Python file with a type error (e.g., 'main.py')
# echo 'def greet(name: str) -> str:\n    return f"Hello, {name}"\n\nprint(greet(42))' > main.py

# 5. Run Pyrefly to check for type errors
# pyrefly check

# Expected output for 'print(greet(42))' should show a type error, e.g.:
# main.py:3:11: Type mismatch: Expected `str` but got `int`

view raw JSON →