Just make Typethon.
If it becomes so widespread, we might see a direct integration into Python in a future release, like how we got dataclasses
I mean, it should just be TypedDataClasses. But I think if you look at the Pydantic docs you will see why it can't just go into the standard library, Pydantic type coercion and exceptions are probably as random sounding as JavaScript
"First time?"
~JS users who've had TypeScript rammed down their throats for over a decade.
Ehh but there are lots of type validation libraries in typical JS fashion
Are there none other than Pydantic for Python?
there's msgspec and attrs
It’s 2025. Type validation and serde should be built into the language.
I don't know, seems like if you want strict typing you just don't use Python.
You really can’t choose in certain fields though, e.g. data science. What am I gonna use? Scala?
R
R is literally one of the worst language out there and thank God it's getting squeezed out from the market by Python and Julia (I know because I use it)
It absolutely is a mess but it’s getting more traction not less. Sorry.
No, I don’t use it, I’m just vaguely interested in it for non-professional reasons
... more traction because of its massive GIS and scientific publishing ecosystem (the reasons I also use it for), but outside of academia I very rarely see it being used.
Sure but it’s gone a long way from an experimental stats teaching language in Auckland to being massive in GIS and science worldwide and it’s still rising
Or if when your company decides they must have AI now and since it's tangentially related to AI it must be in Python. >_>
It's not really extravagant to want your program to be strict for some of its inputs.
Python is strongly typed, so in some cases you want to ensure you won't run into type issues at run time that would be due to user/external data. And internally keep it flexible/dynamic.
VSCode installs Pylint with the default Python extension pack which makes the dev experience like a cleaner version of Typescript.
It can be nice to have both, I like having separate components that talk to each other via heavily validated pydantic models. This way, if any one component isn't doing its job, it fails loudly and quickly at this point of communication.
So why is typescript so popular then? People want strict types with JavaScript so bolted them on during coding time. Most devs don’t even know that at runtime it’s still completely typeless.
Oh you mean why do people use typescript when there's so many inherently strictly typed alternatives to JavaScript available?
Also, I feel like you're underestimating "most devs".
Every piece of software needs to deserialize and validate inputs irregardless of strictness of the language type system.
Honestly I think it's a feature of the language. Python wants to keep the barrier to entry as low as possible and really thrives on people abusing code in ways it wasn't intended for. For example, many functions that just implement specific maths will work on floats, ints, numpy arrays, torch tensors, tf tensors, jnp arrays, awkward arrays, pandas data frames and dask dataframes. If python was too strongly typed you wouldn't be able to use code someone has written thinking it's for numpy on your jax arrays, or even worse would cast your jax array to numpy
Serde and validation are not the same as strong/weak typing. They are very specific to program inputs/outputs.
Facts. So many Python scripts over the years have failed in the middle of execution for some stupid type reason.
Skill issue.
No, it shouldn't, because then it will end up like TS where it's only a paint job on top and I in spend half my time writing boilerplate that doesn't even actually reduce the number of bugs in the product.
TS is neither a serde nor a validation tool. It only provides type guards in your code.
having to deal with typing in python is such a pain in the ass when you are used to real statically typed languages
For me the worst part is that sometimes you can hit a case in which the type checker chooses to say bye without telling you. So, you trust that you haven't committed a mistake until it blows your face.
lol, wtf. I always See people complaining about typing in Python while there are proper tools and solutions. Would it been better If typing hadn't been an afterthought? Defenitely. But the Status quo IS really good. (Except for the case where you have dependencies that have no proper types...)
However, this is not what pydantic addresses. Pydantic actually uses the flexibility and reflection abilities of Python to provide annotations and Checks that would be Impossible in other strictly typed languages like C++ out of the box.
HAHAHA LOL
If you want strict typing... Why are you usin python?
Wait, can't you already static type any variable and argument if you wish?
Yes, yes you can! And for 99% of cases, you don't even need the typing
package (which is btw part of the standard installation).
This meme is just nonsense. if i'm forced to use python, i use pydantic to easily "validate" that "unstructured" data i received via a post request or that has been read from a file is what i expect it to be, structurally 🤔
I only just started learning python, what does the typing package do?
I fucking held off for sooooo long to even bother to learn typing in python. And now I love it and kinda still fucking hate it. Mypy can fuck right off tho. We have that in one of our git actions and fuck mypy to hell.
Mypy is literally the worst. So many hours spent fighting inane and impossible errors
The problem is our OCD. If you write a new simple function, please, type it. If you tackle an old Django app, please don't try and make the types work.
and it’s so bloated and slow as well
Idk how anyone can work on a larger python project (>5k LOC). I came from game dev and work in enterprise 3D projects. We switched from Unreal Engine to Nvidia Omniverse
I worked with Python for a few scripts and I understand it's usefulness for niche, small utilities. But using Python for anything realtime is god awfully slow.
The type checker in VSCode can't handle larger projects and generally, I'd preffer a compiler/VM to tell me errors straight away if the code is invalid, rather than nothing happening until the invalid code is ran
[deleted]
If types give you the feeling something is difficult, then the person should not be a programmer. How can one even write code without knowing all the time what type a certain variable is supposed to be, is beyond me. Hence why I use strict type checking when writing Python, but not all libraries have good type support, sadly.
It's nice to have type checking sometimes, for example when pulling data from an API or for communication between subsystems. Adding this functionality to the standard library wouldn't fundamentally change the language, it's just another tool in the toolbox.
But... Python has types? What are you talking about?
It's just about static typing and that would make stuff easier actually as you don't have to check stuff manually at runtime. Would be kinda simple, just use the type hints, and if they don't match, just abort the initial compilation step. Just make it opt-in and everything's fine. Dynamic typing just doesn't reflect how people actually use the language, because Python isn't made for beginners, no language is, Python is used quite a bit in environments which would totally benefit from having static type checking.
Java people writing Python.
I feel if you're building something more than a dirty quick script or prototype, just use another language.
Long term maintenance is not a strength of any dynamic typed language.
Lol, Python pulling out that Draw 25 card rather than committing to static typing is such a mood. Can relate, sometimes adding that type-hinting feels like overcommitting to a relationship 😂 #JustPythonThings
ok LLM
We can tell apart now, but it's gonna be scary as fuck in a couple months or 1-2 years, you'll never know who's a bot.
Just piss off Microsoft with Python and they will make Typethon