Congrats on 1.0, this looks really interesting and I'd like to try it. Does ty have any story for Django / DRF yet? I rely on django-stubs and its mypy plugin for models and querysets, so I'm curious how ty handles that kind of dynamic behavior.
I don't think we have any special handling of DRF (yet). It would be good to know exactly what you need there! Feel free to file an issue on GitHub :-)
Why should the type checker have to know anything about Django? What if I want to make a framework with the same shape? Do I submit a PR to Ty? One that I bet would be rejected because I didn't have any users yet? Users who won't come without type checking support?
This style of development is unfair to innovators and ossifies the ecosystem.
Ideally it shouldn't; I don't think anyone would argue otherwise.
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.
The Python typing community has known about the expressiveness problems for years. It's forward-only, has no HKTs, no type computation, no intersection, no complement. I can't even do generic parameter list transforms.
All of these are known deficiencies. Everyone who brings them up is told to pound sand, their use cases deemed illegitimate. Might as well be GNOME.
It's fundamentally unfair that Django gets to use aspects of the language other tools can't, and one hard coded dataclass-style transform is inadequate.
So help me God, if I ever do another large scale Python project, then if these issues aren't fixed in typing, I will vendor and modify a type checker in the project itself and teach it my project's patterns directly. I will not twist and distort my design vision so it rhymes with dataclass.
I agree; we don't like this either. But there is no palatable short-term alternative. If we don't do it, then Django/pydantic/attrs users will just prefer other type checkers that do. The best long-term option is to make all of this expressible in the type system; there are proposals currently under consideration that will go a long way towards this.
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.
These proposals have stalled behind consensus hell for years. Enabling plugins would be a pragmatic option: you could even spell them as HKTs or something right in the source. Or you could enable private type system extensions.
I'm not sure about Django + Ty specifically, but some dependencies need a plugin because they're impossible to type annotate otherwise. For example, sqlalchemy + mypy
sqlalchemy is kind of the counterexample now. they deprecated the mypy plugin in 2.0 because the new typed models just work without it. what still needs special handling is the really dynamic stuff, like django's reverse relations or pydantic turning a string into a Path like in the post.
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.
Curious to see how Ty now compares to Pyrefly in practice. Had to switch from Ty because it was rather poor compared to Pyrefly at the time. A bit spoiled for choice in regards to Python type checkers now.
Last time I evaluated ty and pyrefly, I ended up sticking with basedpyright. Its type inference felt the most complete. Curious to see if things have changed.
I switched from pyright to pyrefly like 6 months ago, and it's been fantastic
so far. It has holes on some packages that use complicated meta-programming tricks, like sqlalchemy, but other than that no issues. It certainly finds more code smells
than pyright for me.
Congrats to the Astral team! I've been using ty since the alpha days. Was so excited to replace pylsp with it, and it's been a mainstay in my arsenal ever since. It's gotten so reliable over the past year or so that I forgot it was pre-1.0 software.
Pyrefly (Meta) has been the preferred type checker in my social circles for Python, for a while now. OpenAI acquisition in this regard has been viewed as a net negative, if anything, for using Astral's tools. OpenAI has yet to establish a track record for maintaining open-source software for years, the company is simply too young.
> So if OpenAI owns Astral, and Microsoft has Pyright, don't two companies effectively dominate both Python and TypeScript ecosystems?
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.
Microsoft owns the .NET ecosystem and the npm ecosystem via GitHub (which in itself is a massive asset). Broadcom basically owns modern enterprise Java stack via SpringSource. Nothing to be seen here apart from companies realizing there is value in ecosystems (decades after Oracle/Java). OpenAI buying Astral (and investing heavily) was a way to dominate the Python ecosystem. Anthropic has bought Oven (i.e. Bun), but the jury is still out on that one in terms of market or ecosystem domination (watch out for upcoming AoT release though).
Congrats to the Ty team. Been using it for a while now.
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.
I got excited when ty came out because the LSP experience was so much better than I had before with pylsp-mypy. But then I lost interest in programming due to AI. I've been watching the releases and it's pretty obvious there's a lot of "AI assisted" development going on. Kinda funny that they're using AI to make a tool which is pointless because of AI.
If there are license changes or any user hostile behavior then you might say they sold out. But so far, they have been improving the ecosystem!
Thanks for the great work team! Congratulations on reaching another milestone.
Tried it on a 10k loc project which never had a type checker: 0.5s, 450 results. More than 400 of them are one pattern, a dict of kwargs splatted into a call (`*kw`). ty infers the dict as `dict[str, str | int]` and flags every parameter against that. Is there any way to type the dict once, or is a TypedDict the way to go?
We do generally support this pattern for dictionary literals, but we can't track the precise types of arbitrary keys if the dictionary is created dynamically, you'd have to use a TypedDict in that case.
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.
Past related threads. Others?
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)
Congrats on 1.0, this looks really interesting and I'd like to try it. Does ty have any story for Django / DRF yet? I rely on django-stubs and its mypy plugin for models and querysets, so I'm curious how ty handles that kind of dynamic behavior.
We added builtin support for django fairly recently! You can read about it here: https://docs.astral.sh/ty/features/third-party/django/
Oh nice, didn't know that, thanks! Does it handle DRF too, or just Django itself? Haven't had a chance to read the docs yet.
I don't think we have any special handling of DRF (yet). It would be good to know exactly what you need there! Feel free to file an issue on GitHub :-)
Thanks for the quick answer! I'll write up what I'd need for DRF and open an issue.
Why should the type checker have to know anything about Django? What if I want to make a framework with the same shape? Do I submit a PR to Ty? One that I bet would be rejected because I didn't have any users yet? Users who won't come without type checking support?
This style of development is unfair to innovators and ossifies the ecosystem.
Ideally it shouldn't; I don't think anyone would argue otherwise.
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
The Python typing community has known about the expressiveness problems for years. It's forward-only, has no HKTs, no type computation, no intersection, no complement. I can't even do generic parameter list transforms.
All of these are known deficiencies. Everyone who brings them up is told to pound sand, their use cases deemed illegitimate. Might as well be GNOME.
It's fundamentally unfair that Django gets to use aspects of the language other tools can't, and one hard coded dataclass-style transform is inadequate.
So help me God, if I ever do another large scale Python project, then if these issues aren't fixed in typing, I will vendor and modify a type checker in the project itself and teach it my project's patterns directly. I will not twist and distort my design vision so it rhymes with dataclass.
I agree; we don't like this either. But there is no palatable short-term alternative. If we don't do it, then Django/pydantic/attrs users will just prefer other type checkers that do. The best long-term option is to make all of this expressible in the type system; there are proposals currently under consideration that will go a long way towards this.
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.
These proposals have stalled behind consensus hell for years. Enabling plugins would be a pragmatic option: you could even spell them as HKTs or something right in the source. Or you could enable private type system extensions.
I'm not sure about Django + Ty specifically, but some dependencies need a plugin because they're impossible to type annotate otherwise. For example, sqlalchemy + mypy
sqlalchemy is kind of the counterexample now. they deprecated the mypy plugin in 2.0 because the new typed models just work without it. what still needs special handling is the really dynamic stuff, like django's reverse relations or pydantic turning a string into a Path like in the post.
Exactly. Why are we baking support for this or that package to the core instead of enabling plugins or just making the type system more expressive?
Too bad it doesn't support Django 6.
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.
> ty also includes built-in support for foundational Python libraries like Pydantic, Django, pytest, and attrs
Does adding `django-stubs` not work?
I haven't tried it myself, as I don't use Django.
No, it doesn't support reverse relations for example
Curious to see how Ty now compares to Pyrefly in practice. Had to switch from Ty because it was rather poor compared to Pyrefly at the time. A bit spoiled for choice in regards to Python type checkers now.
Hah. I just switched from Ty to Pyrefly last night. Like 15 hours ago. I guess it was a good exercise, but now I want to compare this release.
Would be happy to know where we could do better, if you do this comparison on your codebase today. GH issues are open!
> at the time
Any indication of when that was? Just being curious.
Been using Ty for nearly a year or so now on my Django backend. Been very impressed as I've seen the versions tick up and up. Thanks for this.
Last time I evaluated ty and pyrefly, I ended up sticking with basedpyright. Its type inference felt the most complete. Curious to see if things have changed.
I switched from pyright to pyrefly like 6 months ago, and it's been fantastic so far. It has holes on some packages that use complicated meta-programming tricks, like sqlalchemy, but other than that no issues. It certainly finds more code smells than pyright for me.
Congrats to the Astral team! I've been using ty since the alpha days. Was so excited to replace pylsp with it, and it's been a mainstay in my arsenal ever since. It's gotten so reliable over the past year or so that I forgot it was pre-1.0 software.
running ruff + mypy + pytest after every change, ruff is basically instant while mypy is always the slow part of the loop.
So if OpenAI owns Astral, and Microsoft has Pyright, don't two companies effectively dominate both Python and TypeScript ecosystems?
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.
Pyrefly (Meta) has been the preferred type checker in my social circles for Python, for a while now. OpenAI acquisition in this regard has been viewed as a net negative, if anything, for using Astral's tools. OpenAI has yet to establish a track record for maintaining open-source software for years, the company is simply too young.
> So if OpenAI owns Astral, and Microsoft has Pyright, don't two companies effectively dominate both Python and TypeScript ecosystems?
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.
Microsoft owns the .NET ecosystem and the npm ecosystem via GitHub (which in itself is a massive asset). Broadcom basically owns modern enterprise Java stack via SpringSource. Nothing to be seen here apart from companies realizing there is value in ecosystems (decades after Oracle/Java). OpenAI buying Astral (and investing heavily) was a way to dominate the Python ecosystem. Anthropic has bought Oven (i.e. Bun), but the jury is still out on that one in terms of market or ecosystem domination (watch out for upcoming AoT release though).
Congrats to the Ty team. Been using it for a while now.
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.
Congrats! This is a huge milestone. Out of curiosity, what will it take to get Ruff and UV to 1.0.0?
Watch this space :-)
I got excited when ty came out because the LSP experience was so much better than I had before with pylsp-mypy. But then I lost interest in programming due to AI. I've been watching the releases and it's pretty obvious there's a lot of "AI assisted" development going on. Kinda funny that they're using AI to make a tool which is pointless because of AI.
But type checking is useful to AI?
I thought everything can be vibe coded in Rust. Turns out OpenAI are Luddites and use Python.
Remember when Astral told us in 2024 they would not sell out?
If there are license changes or any user hostile behavior then you might say they sold out. But so far, they have been improving the ecosystem! Thanks for the great work team! Congratulations on reaching another milestone.
everybody sells out at the right price. You're a sellout just by working for someone.
By sellout they mean someone breaking promises for money. Not someone who is selling things/skills/time for money.
Nope. Getting paid and selling out are distinct things. It depends on whether your integrity is included in the sale price.
congrats to the team!
Tried it on a 10k loc project which never had a type checker: 0.5s, 450 results. More than 400 of them are one pattern, a dict of kwargs splatted into a call (`*kw`). ty infers the dict as `dict[str, str | int]` and flags every parameter against that. Is there any way to type the dict once, or is a TypedDict the way to go?
We do generally support this pattern for dictionary literals, but we can't track the precise types of arbitrary keys if the dictionary is created dynamically, you'd have to use a TypedDict in that case.
Typing spec has some detailed info if you'd like https://typing.python.org/en/latest/spec/typeddict.html
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.