Ty: A fast Python type checker and language server

github.com

903 points by arathore 6 days ago


zanie - 6 days ago

:wave:

Looks like you found the not-so-secret repository we're using to prepare for a broader announcement :)

Please be aware this is pre-alpha software. The current version is 0.0.0a6 and the releases so far are all in service of validating our release process. We're excited to get this in people's hands, but want to set the expectation that we still have a lot of work left to do before this is production ready.

Stay tuned for more for news in the near future!

(... I work at Astral)

ngoldbaum - 6 days ago

I gave away the “ty” project name on pypi to Astral a week or so ago. I wanted to use it for a joke a few years ago but this is a much better use for a two letter project name. They agreed to make a donation to the PSF to demonstrate their gratefulness.

aleksanb - 6 days ago

The way these type checkers get fast is usually by not supporting the crazy rich reality of realworld python code.

The reason we're stuck on mypy at work is because it's the only type checker that has a plugin for Django that properly manages to type check its crazy runtime generated methods.

I wish more python tooling took the TS approach of "what's in the wild IS the language", as opposed to a "we only typecheck the constructs we think you SHOULD be using".

tmvphil - 6 days ago

Just compared the time to check on a fairly large project:

- mypy (warm cache) 18s

- ty: 0.5s (and found 3500 errors)

They've done it again.

Handprint4469 - 6 days ago

If you have uv installed, you can test it without installing by running:

  uvx ty check
blibble - 6 days ago

prior to astral appearing, python's tooling has been beyond terrible, compared to say, Java's

astral have now replaced the awful pip with the fantastic uv

various awful linters with with the fantastic ruff

and now hopefully replacing the terrible type checkers (e.g. mypy) with a good one!

I hope they have the pypi backend on their list too, my kingdom for Maven Central in python!

rexledesma - 6 days ago

Very excited to have a new fully featured Python language server working in both vscode and vscode forks (e.g. Windsurf, Cursor).

Pylance is borked on these forked distributions, so having a new solid alternative here that doesn't involve adopting yet another forked Pyright implementation (BasedPyright, Cursor Pyright, Windsurf Pyright, ...) sounds great to me.

hamandcheese - 5 days ago

Not the most fun question, but as I see Astral taking over the python ecosystem, I can't help but wonder: how do y'all plan to make money? It seems like you've taken VC funding, so monetization is inevitable.

krupan - 6 days ago

Have these guys figured out how to make money yet?

nickagliano - 6 days ago

Interesting to see astral come out with this right around facebook’s release of “Pyrefly, a faster Python type checker written in Rust”.

Not making any sort of ethical statement, just interesting that rust keeps eating the python and JS tooling worlds.

cristea - 6 days ago

Will it support Django stubs? Only blocker for my company to switch

tayo42 - 6 days ago

Curious why so many people want to implement type checkers for python? What problems are being solved that aren't covered already?

pamelafox - 6 days ago

I am literally checking HackerNews while I wait for mypy to finish running, so I am excited to hear a faster type checker is on the way! Hope the error messages are also helpful.

tiltowait - 6 days ago

I've been looking forward to this since the original announcement (and before, really).

On the modest codebase I tried it on (14k LOC across 126 files), it runs in 149ms compared to 1.66s in pyright (both run via uvx <tool>). I couldn't get it to play nicely with a poetry project, but it works fine (obviously) in a uv project.

Definitely some false-positives, as expected. Interestingly, it seems to hate the `dict()` initializer (e.g. `dict(foo="bar")`).

throwaway63467 - 6 days ago

I was wondering when someone would write a type checker in Rust, seemed like an obvious thing to do given how slow mypy is.

- 6 days ago
[deleted]
urbandw311er - 6 days ago

It’s like when we hit a new month the quota of “talk about Rust” credits is renewed.

no_time - 6 days ago

Awesome work. What is the business model for these astral tools? It’s a bit of a “waiting for the other shoe to drop” feeling after seeing the VC backing on the company page.

Sarios - 6 days ago

Perhaps a silly question. Will ty be usable for getting semantical completions / suggestions. Similar to using pyright to get completions based on what's being written.

pizza - 6 days ago

Probably not a top priority but it would be really really cool if this thing had solid t-string support from the jump, to the extent that it’s feasible without actually executing code

rowanG077 - 6 days ago

Recently I started a python project and I wanted to do it the "proper" way. mypy + pylint. But even on this small 15-20kloc program these tools are way to slow to do anything in realtime. It takes double digit seconds to have feedback. Way to long for an LSP. I'm honestly appalled the state of affairs is this bad. What the hell do people do with moderately or even large sized code bases?

kodablah - 6 days ago

Fingers crossed this is/becomes extensible. Pyright and MyPy both suffer from lack of extensibility IMO (Pyright doesn't consider the use case and MyPy plugins come across as an afterthought with limited capabilities). There are many things that can be built on the back of type-checked AST.

Affric - 6 days ago

See the thing about astral is that they get why Python has been successful in the first place:

When it was released it might have been one of the easiest to use languages.

The focus on tooling and making the tooling fast has been sharp. Seeing people recommend using non-astral tooling seems nuts at this point.

cyounkins - 6 days ago

How does Astral plan on making money?

The-Ludwig - 5 days ago

If this will be only 50% as awesome as ruff or uv, it will be a future must-have for me.

simlevesque - 6 days ago

I installed it in VSCode and removed Mypy, I haven't looked back: https://marketplace.visualstudio.com/items/?itemName=astral-...

joshdavham - 6 days ago

Any plans to create an official ty github action? I've been loving the ruff github action.

drcongo - 6 days ago

I've been looking forward to this for what seems like an age.

f311a - 6 days ago

Does it support go to definition and other lsp features?

briandw - 6 days ago

Looks good but it has the same issues that i have with mypy. Packages that don't include the type hints blow-up my process. In mypy i've come to terms with strategically ignoring packages or finding a package of type hints. Mypy is runs cleanly on my project but I get >800 errors with TY, mostly things like:

lint:unresolved-import: Cannot resolve imported module `pydantic` --> vartia/usr_id.py:4:6 | 2 | from typing import Optional, Any 3 | from enum import Enum 4 | from pydantic import BaseModel, ConfigDict

looking forward to the release version.

ljouhet - 6 days ago

uv is an incredible tool ; ty will be also. It's insanely fast

For now, I have some false negative warnings :

'global' variables are flagged as undefined `int:unresolved-reference: Name ... used when not defined` (yeah, it's bad, I know)

f(*args) flagged as missing arguments `lint:missing-argument: No arguments provided for required parameters ...`

robertwt7 - 6 days ago

This will be similar to Typescript I assume? If so I can’t wait to use it!! I cant count how many times I’ve searched for “TS like in Python” since I’ve started working on Python codebase. TS is so awesome that I use it 100% on new projects. Ruff is also very good, but with this, large code base Python will be a breeze to work with

TeeMassive - 5 days ago

Glad to see that we have the type-checking equivalent of Ruff!

joejoo - 6 days ago

Astral killing it with the Python tooling.

sestep - 6 days ago

Is this the same thing as Red Knot?

dhruv3006 - 5 days ago

Great job!

ivanbelenky - 6 days ago

holy shit this is happening

selfselfgo - 6 days ago

[dead]

canterburry - 6 days ago

How about we just stop creating non type safe languages. Would save everyone so much hassle.

[bring on the downvotes]