726 points · by burntsushi · 2d ago · 162 comments
At the time, ty had a conformance suite pass rate of 53% and pyrefly of 88% vs. pyright's 98% (and I didn't know zuban)
Now [1] pyrefly and zuban both sit at 100%, ty at 97% and pyright at 96%
Time to re-evalute
[1] https://github.com/python/typing/blob/main/conformance/resul...
https://github.com/adsharma/fquery/blob/main/tests/django_ex...
https://github.com/adsharma/fastapi-shopping/blob/main/src/f...
https://gist.github.com/rtpg/ac1950e6c390ddd7a02ddc941ee75c5...
I beg everyone thinking of writing an ORM or a validation framework to look at my gist and internalize it. You don't need top-level type annotations to get type checking form mypy and friends!
People's first idea when trying to tackle types in Python is "OK I want this field to be an int so I will have an API that labels it an int" but if you lean into descriptors you will get a much more flexible system that can handle more scenarios.
Being able to distinguish "types that can be written to a field" from "types that are read from a field" in particular are _so straightforward_ all things considered.
This doesn't solve a lot of the reverse relation issues and annotations on querysets but neither does your library.
I maintain one such transpiler.
Dependent types that can be machine translated to lean4 proposed here. Google static python skill.
This is not true. Python's typing system is based on two typing formalisms that are well studied in the academic literature: set-theoretic typing and gradual typing. We've drawn a lot of inspiration in particular from the work done by Giuseppe Castagna and his collaborators.
Elixir's type system is based on exactly the same formalisms, and our teams have met several times to share notes on the underlying concepts, and on implementation techniques. Guillaume Duboc's PhD thesis, which he defended earlier this year, is a particularly strong example of this; we were able to implement an incredibly effective optimization [1] based on his work optimizing disjunctive types in Elixir's type checker.
Now, it's definitely true that Python is a very complex language, and so its type system does not (and cannot) implement the academic set-theoretic algorithms directly. But it provides exactly the formalism that we need to reason about the kinds of code that appears in real-world Python programs.
I mean just abstractly speaking you can define semantics on a typing relation that behaves this specific way based on a class definition. You have to futz around a bit to distinguish writes from reads, but it's "just" busywork IMO. I don't believe there's some semantic difficulties there. Subtyping issues are way worse than this, at first blush (ready to be told otherwise though!)
> I'm also of the opinion that any such type enhancements have to be friendly towards machine translation to Rust.
I mean that's your opinion. I have nothing against Rust and use it but my objective in using Python is to use Python.
Despite the name containing dataclass, it can work for Django.
Theorically, you can now do this: https://www.pystebin.com/p/06b0fd4e-e84c-7099-8000-09197d731...
Django does not use it right now, and we are limited to using stubs. They do work pretty well.
But what I mean is, it's not limited by Python type design anymore.
I've argued with pydantic, sqlmodel and Django people that they should replace them with decorators instead.
This will primarily help with automatic translation to Rust.
It doesn't cover querysets, but it covers most of the model attributes automatically. It's not 100% perfect but it's way better than nothing and it allows you to check a lot of things ty and pyright.
They have benchmark graphs which aren't properly labeled; the links (when they exist below) do not give a more full picture (you just have to jump back and forth and try to map the table to the graphs somehow?); and the year-over-year growth chart feels weird. The YoY chart makes me want to know more about why mypy grew 4x from 2025 to 2026 than it makes me feel like Ty has healthy growth. It also is concerning why they chose to emphasize growth of the user base over the actual type checking advantages that Ty gives: especially the advancements 1.0 gives.
It's a mishmash of information and feels lacking.
A healthy ecosystem around a tool is important, especially a type checker since you want library authors to prioritize a good experience for your tool of choice. It is noteworthy here that ty adoption has grown significantly beyond the rates of other tools.
`mypy` has caught missed pieces of refactors that were simply never checked anywhere else. It’s found confusing type declarations and outright logic errors, way more than I thought it would in an otherwise well-structured and heavily annotated code base.
(I am on the team and can look into improving them if something can be clearer)
What do any of these mean? What distinguishes the one in the top left from the other clusters of bars?
We should also support attribute docstrings everywhere now.
Any indication of when that was? Just being curious.
"Spoiled" is not the word I'd use. In my admittedly brief experience all the Python type checkers are terrible in practice, and the problem is Python. You know in which languages type checkers work? Elm, Gleam, Haskell, etc. There's usually one type checker and it works – there's no need to create several competing-but-all-broken-in-various-ways type checkers.
Ty – A fast Python type checker, written in Rust - https://news.ycombinator.com/item?id=46100637 - Nov 2025 (15 comments)
Pyrefly vs. Ty: Comparing Python's two new Rust-based type checkers - https://news.ycombinator.com/item?id=44107655 - May 2025 (160 comments)
Ty: A fast Python type checker and language server - https://news.ycombinator.com/item?id=43918484 - May 2025 (287 comments)
But even then, when I switched from pyright to ty, I was really amazed at how fast operations like go-to-definition can be. With pyright, the language-server-based go-to-definition is often slower than ripgrep search.
I’m thinking the reasoning must go something like “Claude writes all my code but at least I can make it write artisanal meta programming to show how clever I am”.
This style of development is unfair to innovators and ossifies the ecosystem.
But (1) django is older than Python's type system, so it uses some very dynamic patterns that are hard to express using Python types. And (2) it's very popular, which means both that lots of people want their type checker to do Something Useful™ with django code, and that it would be very difficult to retrofit django to use dynamic patterns that _are_ more compatible with the type system. That combination makes it worth our time to add specific custom support for it.
For your own future library, the hope is that the type system has become capable enough that you wouldn't _need_ custom type checker support. Things like `dataclass_transform` [1] were added specifically so that _all_ libraries could express these kinds of things in ways that are visible to the type checkers without custom support.
If you're doing something that still doesn't fit into what the typing system provides, then the Python typing community wants to learn about your use case so that we can see if we can extend the typing system even further to support it.
[1] https://typing.python.org/en/latest/spec/dataclasses.html
Plugins do provide a more level playing field, and we aren't closed to the possibility of supporting them in future. But they come with a whole host of challenging technical problems, and we have a lot of other high-priority things to work on.
Hmm, that's not accurate anymore! We look for your Python installation in a number of places these days -- we should discover system installations on PATH, conda installations, pixi installations, and, yes, local virtual environments. Is your Python installation at `~/.local` on PATH?
Funnily though I’ve started to care less about typing in Python. Since Rust got good most projects where I’d want strong types I’m not using Python anymore. Python is still great for glue code, as it was intended. Typing helps there if libraries have good support but I find myself writing Python type annotations less now. It’s always been a bit awkward and ugly in Python anyway.
In the meantime, I think there are "LSP multiplexers" which can present a single language server to your editor and proxy multiple language servers, though I don't have personal experience using these.
Python's typing system has really matured and with 3.14 most of the ergonomic issues have been ironed out. Between that and AI coding there's no good reason not to have strict type checking on your python code. But mypy is simply too slow to use in practice though so it'll be between ty and pyrefly I guess.
The real issue is that ty's Django support is still early: reverse relations and django-stubs aren't supported yet, and django-types is already lagging behind Django 6.
Does adding `django-stubs` not work?
I haven't tried it myself, as I don't use Django.
https://detachhead.codeberg.page/workproperly/blog/2026/11/2...
> As of writing this, more of the rules covered by basedpyright are covered by *pyrefly* than ty, and there are a few missing features in ty that make it not really feasible to use yet in real projects
(My emphasis.) Seems I'll be switching to pyrefly then.
Detachhead has done such a good job bringing pylance's proprietary features to the masses. I also appreciated how he just cut through the bullshit in the pyright issue tracker.
So reading this part, I feel for him:
> what AI has done to programming has significantly impacted my motivation to work on open source projects. [..] In fact I kinda no longer really enjoy interacting with other developers at all.
In a post-AI world I imagine most projects will reach for a sensible static code alternative.
Python in 2026 is basically as typed as you want it to be. I've been seeing a ton of success from telling my agents to type-hint extensively, and then throw in things like pydantic, which can do all of the messy json-parsing-dict-soup for you behind the scenes, and you have a perfect blend where you have types where they help, and then can skip them where they don't (test code, messy parsing pydantic might not cover, etc).
Agents benefit from the huge amounts of training data, and the ability to interact with the code in a way it can't in rust. Notably, claude (and distillations thereof) are clearly trained to use python for lots of general "bash-ish" type calls, and then your language being python + your code being python then lets it get super creative in exploring and figuring stuff out.
And finally, python being easy and expressive for humans to write carries over to agents too, IME. They just do really well with it.
Just my 2c. Everyone keeps saying they don't read the code anymore, so it might as well be rust. But somehow I keep ending up needing to look at code, and when I do, I still prefer it to be python. And am annoyed when it's not (e.g. at work).
But yeah aside from an AI lab where python was the lingua franca, I haven't felt the need to reach for python itself in years.
I have nothing against Ty, it is quite powerful, and released under MIT.
This blog post also tells us that Ty is used extensively at OpenAI, like we're meant to be impressed.
I got a 2 weeks ban on the python discuss instance for suggesting that core contributors who contribute as their job should disclose who their employer is.
SIGH another one
Summarizing, for something that is an argument with specific fields you'd use a Mapping or a MutableMapping as the annotation, and if that's a return value, then it should be a TypedDict. Sometimes TypedDict also makes sense as an argument annotation, e.g., if it has to be a dict strictly.
For a generic dictionary, like you know that you're drawing from a set of possible kwargs that are all string values, you can also just annotate them with an "anonymous" dict like what Ty is inferring on your codebase.
I don't think it's that bad? They don't sign commits with Codex, the agent-specific documentation is very minimal, human discussion still takes place on every PR. Obviously the devs are using AI to some capacity, that's true of every project still developed these days. Compared to projects like Bun, the AI usage seems perfectly responsible.
For me personally, it's very much the latter -- I extensively review the code my agents write when working on ty. It's fantastic that the codex app, for example, now allows me to use Language Server integrations when I'm reviewing the code that my agents have written. Goto definition, on-hover documentation, etc. in the codex app are all fantastic developments, and they're all powered by language servers.
When I'm working on ty itself, I'm obviously using Rust language servers inside the codex app. But ty is now also the bundled language server for working on Python in the codex app!
Remember when Astral told us in 2024 they would not sell out?
It was VC owned from the start, not a community project.