Pyre is Meta's performant type checker for Python (PEP 484 compliant).
It includes Pysa, a security-focused static analysis tool for taint analysis.
The core engine is written in OCaml (source/), with a Python CLI client (client/).
Note: Pyrefly is the next-generation replacement.
Assume the user is a Meta internal user by default. If the facebook/ directory is missing from the root of the project, the user is an open source user. All buck and arc commands are only available to Meta internal users.
If the file source/dune is missing, this must be a fresh repository clone.
In that case, run the following command:
# For Meta internal users (facebook/ directory exists)
./facebook/scripts/setup.sh --local
# For open source users
./scripts/setup.sh --localcd source && makeThe built binary is at source/_build/default/main.exe.
# All OCaml tests
cd source && make test
# Specific OCaml test - e.g. analysis/test/integration/methodTest.ml:
cd source && dune exec analysis/test/integration/methodTest.exe# For Meta internal users
buck test fbcode//tools/pyre/client/...# For Meta internal users
buck build fbcode//tools/pyre/client:pyreIMPORTANT: Always run linting and formatting after editing files.
For Meta internal users:
# Formatting
arc f
# Linting
arc lintSet PYRE_BINARY to your built binary to override the default:
export PYRE_BINARY=/path/to/source/_build/default/main.exe
pyre -n check # Use one-off check mode, not the server, when recompiling frequentlyBy default, Pysa uses Pyre as its type provider. It can also use Pyrefly instead.
Building the Pyrefly binary requires buck2 (Meta internal only):
buck2 build --show-full-simple-output @fbcode//mode/opt fbcode//pyrefly/pyrefly:pyrefly
# This prints a path like: /data/users/<user>/.../__pyrefly__/pyrefly on stdout.To run OCaml tests with Pyrefly, set the PYREFLY_BINARY environment variable:
cd source && PYREFLY_BINARY=<path-to-pyrefly-binary> make test- Avoid abbreviations
- Prefer
snake_casefor variables/functions,CamelCasefor modules/classes