The latest buzz in the Python industry is revolving around Meta’s official stable release of Pyrefly, a fast Python type checker. There’s a very good reason as to why this is gaining traction really quickly and making headlines.

Pyrefly is a Python type checker written in Rust that checks 1.85M lines of code per second, which is significantly faster than every type checker on the market as of May 2026 (let’s see how quick this becomes outdated!).

» It takes 30 seconds to scan the entire codebase for Instagram - over 20M lines of code 🤯

Let’s cover what type checking is, what it does, and how to go about installing Pyrefly.

What is type checking?

Type checking is a static analysis that reads your source code without running it. These tools walk your code and make sure that you’re using the intended data types.

For example, if you state that a function takes a string, but you accidentally pass in a boolean:

def greet(name: str) -> str:
    return f"Hello, {name}!"

# Passing a bool where a str is expected
result = greet(True)
print(result)

Python will run this code with no issues. However, a type checker will flag this and say that you’re passing in a boolean. If we use mypy:

$ mypy example.py
example.py:6: error: Argument 1 to "greet" has incompatible type "bool"; expected "str"  [arg-type]
Found 1 error in 1 file (checked 1 source file)

» For context, type hints are the annotations that you write into your code, such as -> bool, : int, and so forth. I’ve covered type hinting here and put a cheat sheet together for the syntax.

The Jobs of Type Checking

There’s 3 primary jobs type checking does:

  • Infers types you didn’t write. When you assign x = 42, the checker figures out that x is an int without you explicitly saying so.

  • Defines types you write yourself, usually on function signatures (like :int or -> bool). The checker enforces them.

  • Composes types from other types for anything more than a “primitive”. This is generally data types/structures like a list of strings, an optional dictionary, union of types; these are built by combining simpler types into specific ones.

If we were to put some code to clarify the 3 jobs, it would look something like this:

# Job 1: inferring; the data type isn't explicitly written
user_id = 42                      # int
emails = ["[email protected]", "[email protected]"]   # list[str]
config = {"debug": True}          # dict[str, bool]

# Job 2: defining the data types
def send_invoice(user_id: int, amount: float) -> bool:
    ...

# Job 3: composing
def find_user(user_id: int) -> dict[str, str] | None:
    # returns a user record, or None if not found
    ...

Picking a type checker for your application

SSince Python doesn't ship with a type checker, you’ll need to pick a tool and run it against your code. There’s 4 that are worth choosing from:

  1. mypy - the original, maintained by the Python typing community since 2012. Slow on large codebases, but the safest choice if you're following along with external tutorials, as it’s widely documented (mypy documentation).

  2. pyright - Microsoft's, and the engine behind Pylance in VSCode. Checks unannotated functions by default and has strong typing-spec conformance (pyright documentation).

  3. Pyrefly - Meta's, Rust-based, hit stable 1.0 in May 2026. The most aggressive on inference and the fastest of the current tools (pyrefly documentation).

  4. ty - Astral's (the uv and ruff team), also Rust-based (ty documentation).

Why Pyrefly is getting the attention

There’s a few things that stand out with Pyrefly:

  • Speed - it’s Rust-based and multi-threaded (we’ve seen a lot of packages get implemented with rust, such as uv).

  • You don’t need to annotate anything. Pyrefly’s biggest advantage is that you can point it at a codebase with zero type hints and it’ll still do it’s thing.

To get started with it, you’ll install it using pip or uv, and then initializing it:

pip install pyrefly

pyrefly init

Pyrefly can also migrate an existing mypy or pyright configuration; there’s also a VSCode extension that you can add to VSCode.

Happy coding!

📧 Join the Python Snacks Newsletter! 🐍

Want even more Python-related content that’s useful? Here’s 3 reasons why you should subscribe the Python Snacks newsletter:

  1. Get Ahead in Python with bite-sized Python tips and tricks delivered straight to your inbox, like the one above.

  2. Exclusive Subscriber Perks: Receive a curated selection of up to 6 high-impact Python resources, tips, and exclusive insights with each email.

  3. Get Smarter with Python in under 5 minutes. Your next Python breakthrough could just an email away.

You can unsubscribe at any time.

Interested in starting a newsletter or a blog?

Do you have a wealth of knowledge and insights to share with the world? Starting your own newsletter or blog is an excellent way to establish yourself as an authority in your field, connect with a like-minded community, and open up new opportunities.

If TikTok, Twitter, Facebook, or other social media platforms were to get banned, you’d lose all your followers. This is why you should start a newsletter: you own your audience.

This article may contain affiliate links. Affiliate links come at no cost to you and support the costs of this blog. Should you purchase a product/service from an affiliate link, it will come at no additional cost to you.

Reply

Avatar

or to participate

Keep Reading