New from Facebook: Meet Pyre, a static type checker for Python

Gabriela Motroc
© Shutterstock / Pavlo S

If you’re working on large Python codebases, you’ll need Pyre, a new tool from Facebook, which promises to help improve the quality and development speed by flagging type errors interactively in your favorite editor. Let’s have a look at it.

Facebook recently announced Pyre, a static type checker for Python. If you’re working on large Python codebases, this tool should help improve the quality and development speed by flagging type errors interactively in your favorite editor.

Pyre checks the gradual type annotations which are already part of the Python programming language (PEP484). If you want to give it a try, visit or check out the code at!

Challenges and goals

When you work on a large Python codebase, you should expect to lose some of Python’s benefits. Here are some challenges, as explained in the blog post announcing Pyre:

  • The lack of static guarantees can make it harder to safely make changes to an existing codebase, making the code more error-prone and actually slowing down development relative to statically typed code.
  • It is challenging to build high-quality tools like code search, autocomplete, navigation, and refactoring support; lacking tools like these is especially detrimental when working in a large codebase.

That being said, Facebook built Pyre to be a fast PEP 484-compliant type checker and a platform for building deeper static analysis tools.

If you want to write readable, idiomatic Python, you’ll need a tool that’s “designed to be highly parallel, optimizing for near-instant responses so that you get immediate feedback, even in a large codebase.” This is where Pyre comes into play. You should also know that you can still get useful results even if you’re “not fully committed to static typing, or if you have an existing codebase that you intend to convert gradually over time.”

What’s under Pyre’s hood

Pyre runs as a server which constantly updates its understanding of your code in memory; to make that happen, this tool uses Watchman. 

Furthermore, it maintains a dependency graph representation of your code so when the code changes, it will only re-analyze the code that changes, as well as its direct dependencies, updating the dependency graph as needed along the way.

Beyond type checking, Pyre supports quite a few features, such as automatic re-checking of edited files, through the Language Server Protocol (LSP).

Get started with Pyre

If you want to install Pyre on your system, you’ll need to run pip install pyre-check and that’s it! Run it on your project with pyre --source-directory . check.

Keep in mind that you’ll need Python 3.5 or later to run Pyre. Also, Windows is not supported.

See for details on installing Pyre from a packaged version or from source.

Gabriela Motroc
Gabriela Motroc was editor of and JAX Magazine. Before working at Software & Support Media Group, she studied International Communication Management at the Hague University of Applied Sciences.

Inline Feedbacks
View all comments