Registry / testing / pyrefly

pyrefly

JSON →
library0.60.2pypypiunverified

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.

pip install pyrefly
INSTALL
IMPORT
SIG · PYREFLY
P
pyrefly
testingpythonv0.60.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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`
pyrefly --version
Debug
Known issues
breakingThe `pyrefly-pre-commit` hook underwent significant changes from version 0.0.1 to 0.42.0. Users migrating from older versions need to update their pre-commit configuration.
fix
Migrate your `.pre-commit-config.yaml` to use the consolidated `pyrefly-check` hook. Refer to the `pyrefly-pre-commit` GitHub repository for specific migration steps.
affects: <0.42.0 to >=0.42.0
gotchaWhen upgrading Pyrefly (or its dependencies), new type errors might appear due to improved analysis or stricter checks. Addressing all at once can be impractical.
fix
Use `pyrefly check --suppress-errors` to temporarily silence existing errors, followed by `pyrefly check --remove-unused-ignores` after running your code formatter. Repeat until a clean state is achieved.
affects: All versions
gotchaThe `pyrefly init` command may report a 'No Python files matched patterns' error if run in an empty directory. This is expected behavior and will resolve once Python files are added to the project.
fix
This is not an actual error, but an informational message. Proceed to add your Python or Jupyter Notebook files to the project.
affects: All versions
gotchaSupport for integrating with specific build systems (e.g., Buck2) is currently unstable and may break without prior notice. These issues are generally lower priority than core type-checking functionality.
fix
Be aware of potential instabilities if relying on Pyrefly's build system integration. Monitor official documentation and GitHub issues for updates and workarounds.
affects: All versions
Errors
Common errors & fixes
pyrefly: command not found
The 'pyrefly' executable is not found in your system's PATH, usually because it was not installed or its installation directory (~/.cargo/bin) is not configured in the PATH.
fix
Install pyrefly using `cargo install pyrefly` and ensure that `$HOME/.cargo/bin` is added to your shell's PATH (e.g., by adding `export PATH="$HOME/.cargo/bin:$PATH"` to your `.bashrc`, `.zshrc`, or `.profile` file).
ERROR: Could not find a version that satisfies the requirement pyrefly
Pyrefly is a Rust-based binary and is not distributed via PyPI, so it cannot be installed using 'pip'.
fix
Install pyrefly using the Rust package manager: `cargo install pyrefly`.
error: Missing pyre configuration file
Pyrefly requires a '.pyre_configuration' file in your project's root (or a parent directory) to define the type checking environment, source directories, and stubs.
fix
Navigate to your project's root directory and run `pyrefly init` to generate a default configuration file.
Language server exited unexpectedly.
The Pyre/Pyrefly VS Code extension (or similar IDE integration) failed to start the 'pyrefly' language server executable, often because 'pyrefly' is not installed or not discoverable in the system's PATH.
fix
Ensure pyrefly is correctly installed via `cargo install pyrefly` and that the `$HOME/.cargo/bin` directory (where `pyrefly` resides) is included in your system's PATH. Then, restart VS Code or your IDE.
Upgrade
Version history
0.60.2latest on PyPI · released Apr 10, 2026
Audit
Dependencies
PythonrequiredPyrefly is a type checker for Python code.
Agent activity
22 hits · last 30 days
node
18
OpenAI (training)
2
Resources
pyrefly — pip install pyrefly · libregistry