Pyrefly 1.5 vs ty: Unconfigured, Pyrefly Caught 2 of My 25 Bugs
The 60-second version of this test. Subscribe on YouTube
Python now has two Rust type checkers that want to replace mypy. Pyrefly comes from Meta. ty comes from Astral, the team behind uv and Ruff (Astral announced in March that it is joining OpenAI). On November 19, Pyrefly 1.5 shipped with two big claims: it “passes all 146 test files in the typing conformance suite”, and on ty’s own benchmark, “Pyrefly and ty are about even” on speed. ty is still in Beta. Version 0.0.109 came out yesterday.
Speed charts don’t answer the question I actually have. If I add one of these to a Python project today, which one catches more real bugs, and what does it cost me in CI time and noise?
So I wrote 25 small files that each contain one real bug, plus 15 tricky files that are correct. I ran both checkers (and mypy, as the baseline) on all 40. Then I timed all three on SQLAlchemy, a codebase that is already clean under mypy --strict. The biggest result wasn’t about speed. It came from a config file that wasn’t there.
The Setup
- Machine: a 4 vCPU cloud container (Intel Xeon @ 2.10 GHz, 15 GB RAM), Linux, Python 3.13.18.
- ty:
ty==0.0.109from PyPI (Beta). - Pyrefly:
pyrefly==1.5.0from PyPI. - Baseline:
mypy==2.4.1(compiled). - Round 1 code: 40 files I wrote for this test. 25 contain one bug each, marked with
# BUG. 15 are correct code that uses narrowing, generics or decorators, and all 15 run without errors underpython -I. A bug counts as caught only if the checker reports it on the marked line. - Round 2 code: SQLAlchemy at commit
4917592(November 19, 2026),lib/sqlalchemy, which is 258 files and 254,421 lines. I also used Rich at commit3a109cc(100 files, 26,426 lines). Each repo was checked against a venv that holds its runtime dependencies. - Timing method: 1 warm-up round, then 5 measured runs per tool, interleaved. I report the median wall-clock time, plus CPU time and peak memory (max RSS) read from
os.wait4()in a small Python harness. Each mypy “cold” run starts by deleting.mypy_cache. ty and Pyrefly have no on-disk cache forcheck.
The commands, run from the repo root:
mypy --python-executable ../venv/bin/python lib/sqlalchemy
ty check --python ../venv lib/sqlalchemy
pyrefly check --python-interpreter-path ../venv/bin/python lib/sqlalchemy
Round 1: 25 Seeded Bugs, Zero Config
Here are three of the 25 bugs. Each is the kind of mistake a type checker is supposed to catch for you:
def size(name: str | None) -> int:
return len(name) # BUG: name can be None
def header(headers: dict[str, str]) -> str:
return headers.get("host").lower() # BUG: .get() can return None
async def fetch_count() -> int:
return 3
async def main() -> None:
n: int = fetch_count() # BUG: missing await
The other 22 cover: a wrong return type, str + int, a typo in a dataclass attribute, a wrong number of arguments, an unknown keyword argument, a wrong TypedDict key, an unsatisfied Protocol, instantiating an abstract class, assigning to a frozen dataclass, reassigning a Final, a Liskov-breaking override, a non-exhaustive match caught by assert_never, list invariance (list[int] passed as list[float]), a violated TypeVar bound, a possibly-unbound variable, an error inside an unannotated function, a ParamSpec decorator called with a wrong argument, no matching overload, a bad from os import ..., an enum member typo, calling an Optional callable, and iterating over an int.
First run: a fresh folder, no pyproject.toml, no config of any kind.
| Checker (no config) | Bugs caught (of 25) | Correct files flagged (of 15) |
|---|---|---|
| mypy 2.4.1 | 23 | 0 |
| ty 0.0.109 | 24 | 1 (warning) |
| Pyrefly 1.5.0 | 2 | 0 |
That’s not a typo. Out of the box, Pyrefly 1.5 caught only the unknown keyword argument and the abstract class instantiation. It let len() on an Optional, a missing await and a str + int through without a word, and printed INFO 0 errors.
The reason is in the line it prints right after:
No `pyrefly.toml` found — using preset `basic`.
basic is, in Pyrefly’s own --help, a “minimal checking preset for unconfigured projects and LSP users”. It covers “a small set of high-confidence, locally-fixable checks” and disables “broader call-shape or assignment validation”. So with no config file, Pyrefly behaves like a quiet editor helper, not like a CI type checker.
Round 1b: Add One Empty File
The fix is tiny. An empty pyrefly.toml, or an empty [tool.pyrefly] table in pyproject.toml, switches Pyrefly to its default preset. That’s also what pyrefly init writes for a new project. I checked all three ways.
touch pyrefly.toml # or: pyrefly init
| Checker | Bugs caught (of 25) | Correct files flagged (of 15) |
|---|---|---|
| mypy 2.4.1 | 23 | 0 |
| ty 0.0.109 | 24 | 1 (warning) |
Pyrefly 1.5.0, default preset | 25 | 1 (warning) |
Pyrefly 1.5.0, strict preset | 25 | 1 (warning) |
With a config file, Pyrefly caught all 25. The differences come down to two bugs:
- Possibly-unbound variable (
valueassigned only inside anif, then returned). Pyrefly reports`value` may be uninitialized [unbound-name]. ty has a rule for it,possibly-unresolved-reference, but it’s off by default. Turn it on with--error possibly-unresolved-referenceor[tool.ty.rules]and ty catches it too. mypy misses it. - A bug inside an unannotated function (
def total(): return 1 + "2"). ty and Pyrefly both check unannotated bodies. mypy skips them unless you pass--check-untyped-defs. I checked that flag too, and with it mypy catches the bug.
The single “correct file flagged” is the same for ty and Pyrefly. It’s a @contextmanager function annotated -> Iterator[int]. Both tools emit a deprecation warning, not an error, because typeshed now marks that overload as deprecated in favor of -> Generator[int]. The code runs fine, so I count it. But it’s a fair hint, not a false positive.
One more data point. My first draft of a “correct” file had a TypeIs[list[str]] guard on a list[object] parameter. mypy and ty both rejected it, and so did Pyrefly with a config. Unconfigured Pyrefly didn’t. All three configured checkers were right: list is invariant, so that guard was invalid. I fixed my file, and the table above uses the corrected version.
Round 2: Speed and Memory on SQLAlchemy
Seeded bugs tell you about coverage. CI time comes from big real codebases. SQLAlchemy is a good stress test: 254k lines, heavy generics and overloads, and it already passes mypy --strict in its own config.
SQLAlchemy has no pyrefly.toml, but it has a [tool.mypy] section, so Pyrefly imports those settings and uses its legacy preset (“useful for codebases migrating from mypy”). I timed that, and I timed --preset default separately.
| SQLAlchemy, 258 files | Wall time (median of 5) | CPU time | Peak memory |
|---|---|---|---|
| mypy 2.4.1, cold cache | 9.39 s | 9.47 s | 338 MB |
| ty 0.0.109 | 1.54 s | 5.39 s | 361 MB |
Pyrefly 1.5.0 (auto legacy preset) | 0.79 s | 2.60 s | 158 MB |
Pyrefly 1.5.0, --preset default | 1.16 s | not measured | 197 MB |
Pyrefly was 1.9x faster than ty on SQLAlchemy, with less than half the memory. With the stricter default preset, it was still 1.3x faster. ty used about twice the CPU time Pyrefly did, so on a 2-core CI runner I’d expect the wall-time gap to stay. I didn’t measure that, though. Both are 6 to 12 times faster than a cold mypy run.
Two fairness checks:
- ty prints rich, multi-line diagnostics, and it printed a lot of them here (see below). So I re-ran it with
--output-format concise. The median was 1.53 s, so rendering isn’t the bottleneck. - mypy has a cache. Re-running it with nothing changed took 0.20 s. In CI you usually restore that cache, so cold mypy is the worst case, not the typical one.
Pyrefly’s own v1.5 benchmark points the same way on this project: 297 ms for Pyrefly against 383 ms for ty on SQLAlchemy, on an M5 Max with 18 threads. On a 4-core box, the gap I measured was wider.
On a smaller codebase the gap goes away. On Rich (100 files), ty took 0.23 s and Pyrefly 0.24 s, with 101 MB and 83 MB of memory. mypy took 2.06 s cold. Below a quarter of a second, neither tool will be the slow step in your CI.
Round 3: The Migration Cost
Both repos are clean under mypy, so every new diagnostic is something you’d have to fix or suppress before you could switch. I don’t call these false positives. Some are real disagreements, and some might be real bugs mypy misses. They’re the size of your first PR.
| mypy-clean repo | ty 0.0.109 | Pyrefly 1.5 (auto legacy) | Pyrefly 1.5 (default) |
|---|---|---|---|
| SQLAlchemy | 2,384 diagnostics | 540 errors + 63 warnings | 2,062 errors + 71 warnings |
| Rich | 41 diagnostics | 29 errors + 3 warnings | not measured |
Part of the gap is about suppression comments. SQLAlchemy has 741 # type: ignore[code] comments, all of them with mypy error codes. Pyrefly reports “967 suppressed”, so it honors them. ty doesn’t. Its docs say a bare # type: ignore suppresses everything, but in type: ignore[...], “codes without a ty: prefix are ignored”. So a mypy-coded ignore doesn’t silence ty. I counted: 472 of ty’s 2,384 SQLAlchemy diagnostics sit on a line that already has a mypy type: ignore. On Rich, it was 20 of 41.
At the default preset, Pyrefly’s count gets close to ty’s. The biggest gap is the preset you start with, not the engine.
Where Pyrefly Wins
- Coverage once configured. 25 of 25 seeded bugs with an empty config file, including the possibly-unbound variable that ty and mypy skip by default.
- Speed and memory on big code. 0.79 s and 158 MB against ty’s 1.54 s and 361 MB on SQLAlchemy, on 4 cores.
- Migrating from mypy. It reads
[tool.mypy], honors your existingtype: ignore[code]comments, andpyrefly initwrites the config for you. - A stable release line. It has been 1.x since May, and ty is still 0.0.x Beta.
Where ty Wins
- Zero-config safety. With nothing set up, ty caught 24 of 25 bugs and Pyrefly caught 2. If someone runs the tool once to “see if it finds anything”, ty gives the honest answer.
- Small projects. On Rich it tied Pyrefly (0.23 s vs 0.24 s). Below a few hundred files, speed is not a reason to pick either one.
- The Astral toolchain. If you already use uv and Ruff, ty’s config lives in the same
pyproject.tomlstyle, and Astral has shipped an experimental uv and ty integration. I didn’t test the editor side. Astral claims much faster incremental updates than Pyrefly in the language server, but I didn’t measure that here.
Decision Table
| Your situation | Pick |
|---|---|
| Large codebase, CI minutes matter | Pyrefly (with a pyrefly.toml) |
Migrating a mypy codebase full of type: ignore[code] | Pyrefly, it honors them |
| New small project, you want it to just work with no config | ty |
| Already all-in on uv and Ruff | ty |
| You need a 1.x release for a “no Beta tools” policy | Pyrefly |
| You add Pyrefly to any project | Commit a pyrefly.toml first, always |
The Verdict
Pyrefly 1.5 wins this clash, by a config file. With an empty pyrefly.toml, it caught all 25 seeded bugs to ty’s 24, checked SQLAlchemy 1.9x faster with less than half the memory, and needs far less cleanup when you move from mypy. Without that file it caught 2 of 25, and its 0 errors looks exactly like a clean project. That is the one trap to know about before you trust it in CI.
ty is the safer tool to drop in with no setup, and on small projects it’s just as fast. If your team lives in uv and Ruff, that’s a real reason to choose it. Just turn on possibly-unresolved-reference, and plan to rewrite your mypy ignore comments.
Caveats: 25 bugs is a small set I designed myself, so it measures common mistakes, not real-world bug density. I timed one large repo and one small repo, on one 4-core machine, with five runs each. I didn’t test the editor or language-server experience, Django or Pydantic plugins, or projects with heavy C extensions like NumPy. Both tools release weekly, so re-run this before you decide. Each run took under two seconds.
Related Articles
More tested tooling clashes:
- bun fmt vs Prettier 3.10: 697 TypeScript Files, Identical Output, 45x Faster — Another native rewrite against the tool it wants to replace.
- Vitest 5 vs Jest 30: Jest Won My Benchmark Until I Changed One Flag — One config setting flipping the result, again.
- FastAPI + SQLModel: The Python API Stack I Actually Recommend in 2026 — A Python stack where a strict type checker pays off.
Enjoying the content? Here are tools I personally use and recommend:
- 🌐 Hosting: Bluehost — simple hosting for a WordPress or PHP site
- 🛒 Tech Gear: My Amazon Store — keyboards, monitors, dev tools I use
Purchases through my links help keep this blog ad-free 💙
Enjoyed this post?
Every clash gets a video: two tools, one real task, a measured winner.
▶ Subscribe on YouTube 🎬 All videos