A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/facebook/pyrefly below:

facebook/pyrefly: A fast type checker and IDE for Python

Pyrefly: A fast type checker and IDE for Python

Currently under active development with known issues. Please open an issue if you find bugs.

Pyrefly is a fast type checker for Python. It's designed to replace the existing Pyre type checker at Meta by the end of 2025. This README describes basic usage. See the Pyrefly website for full documentation and a tool for checking code.

Pyrefly aims to increase development velocity with IDE features and by checking your Python code.

If you have questions or would like to report a bug, please create an issue.

See our contributing guide for information on how to contribute to Pyrefly.

Join our Discord to chat about Pyrefly and types. This is also where we hold biweekly office hours.

There are a number of choices when writing a Python type checker. We are taking inspiration from Pyre1, Pyright and MyPy. Some notable choices:

Pyrefly is split into a number of crates (mostly under crates/):

There are many nuances of design that change on a regular basis. But the basic substrate on which the checker is built involves three steps:

  1. Figure out what each module exports. That requires solving all import * statements transitively.
  2. For each module in isolation, convert it to bindings, dealing with all statements and scope information (both static and flow).
  3. Solve those bindings, which may require the solutions of bindings in other modules.

If we encounter unknowable information (e.g. recursion) we use Type::Var to insert placeholders which are filled in later.

For each module, we solve the steps sequentially and completely. In particular, we do not try and solve a specific identifier first (like Roslyn or TypeScript), and do not use fine-grained incrementality (like Rust Analyzer using Salsa). Instead, we aim for raw performance and a simpler module-centric design - there's no need to solve a single binding in isolation if solving all bindings in a module is fast enough.

Given the program:

1: x: int = 4
2: print(x)

We might produce the bindings:

Of note:

Given the program:

1: x = 1
2: while test():
3:     x = x
4: print(x)

We end up with the bindings:

The expression phi is the join point of the two values, e.g. phi(int, str) would be int | str. We skip the distinction between define and use, since it is not necessary for this example.

When solving x@3 we encounter recursion. Operationally:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4