103 points burntsushi 1 hour ago 21 comments

ethnrob 1 hour ago | parent

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.

pronik 39 minutes ago | parent

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).

arthur-st 22 minutes ago | parent

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.

chrikrah 1 hour ago | parent

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?

ibraheemdev 17 minutes ago | parent

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.

arthur-st 11 minutes ago | parent

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.

wilkystyle 45 minutes ago | parent

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.

fishgoesblub 40 minutes ago | parent

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.

ibejoeb 12 minutes ago | parent

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.

_carljm 6 minutes ago | parent

Would be happy to know where we could do better, if you do this comparison on your codebase today. GH issues are open!

BewareTheYiga 34 minutes ago | parent

Congrats! This is a huge milestone. Out of curiosity, what will it take to get Ruff and UV to 1.0.0?

woodruffw 21 minutes ago | parent

Watch this space :-)

122339817 31 minutes ago | parent

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?

fhn 22 minutes ago | parent

everybody sells out at the right price. You're a sellout just by working for someone.

wpietri 18 minutes ago | parent

Nope. Getting paid and selling out are distinct things. It depends on whether your integrity is included in the sale price.

analog_daddy 7 minutes ago | parent

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.

ocamoss 22 minutes ago | parent

congrats to the team!

natsu529 9 minutes ago | parent

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.

alexwaygood 5 minutes ago | parent

We added builtin support for django fairly recently! You can read about it here: https://docs.astral.sh/ty/features/third-party/django/

WD-42 6 minutes ago | parent

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.