{"id":8511,"library":"pyre-check","title":"Pyre-check","description":"Pyre-check is a performant static type checker for Python, developed by Meta (formerly Facebook). It is compliant with PEP 484 and designed to analyze large codebases incrementally, providing quick feedback. It operates with a client-server architecture and includes Pysa, a security-focused static analysis tool. The library is actively maintained with regular updates.","status":"active","version":"0.9.25","language":"en","source_language":"en","source_url":"https://github.com/facebook/pyre-check","tags":["type checking","static analysis","python","pep484"],"install":[{"cmd":"pip install pyre-check","lang":"bash","label":"Install Pyre-check"}],"dependencies":[{"reason":"Required runtime environment.","package":"Python","version":">=3.8"},{"reason":"Essential for incremental type checking and daemon mode, significantly improving performance for large projects. Install via system package manager (e.g., `brew install watchman` on macOS, `sudo apt-get install watchman` on Ubuntu).","package":"watchman","optional":false}],"imports":[],"quickstart":{"code":"import os\n\nproject_name = \"my_pyre_project\"\nos.system(f\"mkdir {project_name} && cd {project_name}\")\n\n# Simulate project directory\nos.chdir(project_name)\n\n# Setup virtual environment and install pyre-check\nos.system(\"python3 -m venv .venv\")\nos.system(\"source .venv/bin/activate\") # In a real shell, this would activate the venv\nos.system(\"pip install pyre-check\")\n\n# Initialize Pyre configuration\nos.system(\"pyre init --no-watchman-comments --no-touch-pysa\") # simplified for quickstart\n\n# Create a Python file with a type error\nwith open(\"test_file.py\", \"w\") as f:\n    f.write(\"\"\"\ndef greet(name: str) -> str:\n    return f\"Hello, {name}\"\n\ni: int = 'string' # This will cause a type error\nprint(greet(42)) # This will also cause a type error\n\"\"\")\n\n# Run Pyre to check for type errors\nprint(\"\\n--- Running Pyre Check ---\")\nos.system(\"pyre\")\n\n# In a real environment, you'd deactivate with 'deactivate'\n# os.system(\"deactivate\")\n","lang":"python","description":"This quickstart demonstrates setting up a basic Python project, installing `pyre-check` in a virtual environment, initializing its configuration, and running a simple type check to identify errors. The primary interaction with Pyre-check is through its command-line interface."},"warnings":[{"fix":"Install `watchman` via your system's package manager (e.g., `brew install watchman` or `sudo apt-get install watchman`) and ensure it's running when using Pyre.","message":"Pyre-check strongly recommends installing and configuring `watchman` for optimal performance. Without `watchman`, Pyre defaults to non-incremental checks, which are significantly slower, especially on large codebases.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Stay informed about `Pyrefly`'s development if you plan long-term commitment to Meta's Python type-checking tools. Currently, `pyre-check` remains supported.","message":"Meta (the maintainer of Pyre-check) has announced and is promoting `Pyrefly` as its 'next-generation Python typechecker and language server'. While `pyre-check` is still active, this indicates a potential future shift in focus or eventual deprecation of `pyre-check` in favor of `Pyrefly`.","severity":"gotcha","affected_versions":"0.9.x and later"},{"fix":"Add `\"strict\": true` to your `.pyre_configuration` file, or add `# pyre-strict` to the top of individual Python files.","message":"Pyre uses a 'gradual typing' approach by default, meaning it often treats unannotated code or types marked `Any` as implicitly correct. To enforce stricter type checking, which catches more potential issues (e.g., missing annotations or `Any` types), enable 'strict mode' in your `.pyre_configuration` or per file with `# pyre-strict`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Use the `pyre-upgrade` command to automatically insert suppression comments for new errors after an upgrade, then address them systematically.","message":"Upgrading Pyre-check can sometimes surface new type errors due to improved analysis or changes in how types are interpreted. To manage this during upgrades, Meta provides `pyre-upgrade` to automatically suppress newly introduced errors, allowing for gradual resolution.","severity":"breaking","affected_versions":"Across major and minor version upgrades"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure `pyre-check` is fully updated (`pip install --upgrade pyre-check`), restart any running Pyre daemon (`pyre stop` then `pyre start`), and if issues persist, try reinstalling in a fresh virtual environment.","cause":"This error typically indicates an internal version mismatch or a breaking change in `pyre-check`'s internal client-server communication after an update, especially if local client files are out of sync with a running daemon or a newly installed binary.","error":"ImportError: cannot import name 'expand_global_root' from 'pyre_check.client.filesystem'"},{"fix":"Install `watchman` using your system's package manager (e.g., `brew install watchman` on macOS, `sudo apt-get install watchman` on Ubuntu/Debian). Ensure `watchman` is in your system's PATH.","cause":"The `watchman` utility, a file watching service developed by Meta, is not installed or not discoverable in your system's PATH. Pyre relies on `watchman` for efficient, incremental type checking.","error":"ƛ No watchman binary found. To enable pyre incremental, you can install watchman"},{"fix":"Correct the type annotation or the value assignment to ensure type consistency. For instance, if `i: int = 'string'` is the error, change it to `i: int = 123` or `i: str = 'string'`.","cause":"This is a fundamental type error detected by Pyre, indicating a value is being assigned or used with a type that does not match its declared annotation.","error":"ƛ Incompatible variable type [9]: i is declared to have type `int` but is used as type `str`."},{"fix":"Ensure you are using Python 3.8 or newer (`python3 --version`). If your Python version is compatible, try updating `pip` and `setuptools` (`pip install --upgrade pip setuptools`) and clearing pip's cache.","cause":"This usually means your Python version does not meet the `pyre-check`'s `requires_python` specification, or there's a problem with your `pip` environment or PyPI access.","error":"ERROR: Could not find a version that satisfies the requirement pyre-check (from versions: none)"}]}