193 points burntsushi 2 hours ago 38 comments
ethnrob 2 hours ago | parent
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 1 hour ago | parent
arthur-st 1 hour ago | parent
LtWorf 58 minutes ago | parent
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.
chrikrah 2 hours ago | parent
ibraheemdev 1 hour ago | parent
arthur-st 1 hour ago | parent
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 1 hour ago | parent
fishgoesblub 1 hour ago | parent
ibejoeb 1 hour ago | parent
_carljm 1 hour ago | parent
NostraDavid 29 minutes ago | parent
Any indication of when that was? Just being curious.
122339817 1 hour ago | parent
Remember when Astral told us in 2024 they would not sell out?
fhn 1 hour ago | parent
analog_daddy 1 hour ago | parent
ocamoss 1 hour ago | parent
natsu529 1 hour ago | parent
alexwaygood 1 hour ago | parent
natsu529 1 hour ago | parent
alexwaygood 46 minutes ago | parent
natsu529 44 minutes ago | parent
quotemstr 22 minutes ago | parent
This style of development is unfair to innovators and ossifies the ecosystem.
goodoldneon 12 minutes ago | parent
quotemstr 9 minutes ago | parent
_carljm 8 minutes ago | parent
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.
quotemstr 7 minutes ago | parent
dcreager 7 minutes ago | parent
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
WD-42 1 hour ago | parent
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.
BoumTAC 38 minutes ago | parent
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.
NostraDavid 29 minutes ago | parent
Does adding `django-stubs` not work?
I haven't tried it myself, as I don't use Django.
BoumTAC 9 minutes ago | parent
globular-toast 11 minutes ago | parent
edstarch 6 minutes ago | parent