103 points burntsushi 1 hour ago 21 comments
ethnrob 1 hour 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 39 minutes ago | parent
arthur-st 22 minutes ago | parent
chrikrah 1 hour ago | parent
ibraheemdev 17 minutes ago | parent
arthur-st 11 minutes 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 45 minutes ago | parent
fishgoesblub 40 minutes ago | parent
ibejoeb 12 minutes ago | parent
_carljm 6 minutes ago | parent
122339817 31 minutes ago | parent
Remember when Astral told us in 2024 they would not sell out?
analog_daddy 7 minutes ago | parent
ocamoss 22 minutes ago | parent
natsu529 9 minutes ago | parent
alexwaygood 5 minutes ago | parent
WD-42 6 minutes 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.