ProgrammerHumor

isAnyoneElseConcernedWithHowManyThingsPydanticIsInTheseDays

isAnyoneElseConcernedWithHowManyThingsPydanticIsInTheseDays
https://i.redd.it/yvfyqyxikcdf1.png
Reddit

Discussion

Snoo_4779

Just piss off Microsoft with Python and they will make Typethon

18 hours ago
Sculptor_of_man

Just make Typethon.

18 hours ago
philippefutureboy

If it becomes so widespread, we might see a direct integration into Python in a future release, like how we got dataclasses

17 hours ago
Not-the-best-name
:py:

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

15 hours ago
-domi-

"First time?"

~JS users who've had TypeScript rammed down their throats for over a decade.

17 hours ago
rover_G
:c::rust::ts::py::r::spring:

Ehh but there are lots of type validation libraries in typical JS fashion

17 hours ago
-domi-

Are there none other than Pydantic for Python?

17 hours ago
watchYourCache

there's msgspec and attrs

9 hours ago
dr-christoph

having to deal with typing in python is such a pain in the ass when you are used to real statically typed languages

14 hours ago
omega1612
:hsk:

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.

8 hours ago
rover_G
:c::rust::ts::py::r::spring:

It’s 2025. Type validation and serde should be built into the language.

17 hours ago
IMightDeleteMe

I don't know, seems like if you want strict typing you just don't use Python.

15 hours ago
skwyckl
:elixir-vertical_4::py::r::js:

You really can’t choose in certain fields though, e.g. data science. What am I gonna use? Scala?

12 hours ago
WrennReddit

Or if when your company decides they must have AI now and since it's tangentially related to AI it must be in Python. >_>

7 hours ago
Duckliffe

R

11 hours ago
skwyckl
:elixir-vertical_4::py::r::js:

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)

11 hours ago
gregorydgraham

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

11 hours ago
skwyckl
:elixir-vertical_4::py::r::js:

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

11 hours ago
gregorydgraham

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

10 hours ago
LexaAstarof
:py::rust::c::j:

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.

14 hours ago
MinosAristos
:py: :ts: :cs:

VSCode installs Pylint with the default Python extension pack which makes the dev experience like a cleaner version of Typescript.

11 hours ago
ganjlord

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.

14 hours ago
backfire10z

It helps with converting external inputs (like API params) to native types and does other things. It isn’t just about strict typing.

1 hour ago
pentesticals

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.

8 hours ago
IMightDeleteMe

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

5 hours ago
pentesticals

I mean that ironically in relation to the original comment saying why do people use python with typehints instead of using a strongly typed language, as typescript is super popular but doesn’t actually provide any type guarantees at runtime.

And maybe it’s not most, but a large portion of typescript devs think it provides runtime safety. I’ve seen many vulnerabilities where people get into large arguments saying „typescript would have prevented this“ where it doesn’t really do anything. I also have been delivering secure coding training to development teams at large banks, tech companies, FAANG companies, etc, and it’s a pretty common perspective I’ve seen during my trainings.

3 hours ago
rover_G
:c::rust::ts::py::r::spring:

Every piece of software needs to deserialize and validate inputs irregardless of strictness of the language type system.

6 hours ago
ChalkyChalkson

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

11 hours ago
rover_G
:c::rust::ts::py::r::spring:

Serde and validation are not the same as strong/weak typing. They are very specific to program inputs/outputs.

6 hours ago
Duke0200 OP

Facts. So many Python scripts over the years have failed in the middle of execution for some stupid type reason.

17 hours ago
abolista

Skill issue.

11 hours ago
raimondi1337

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.

14 hours ago
rover_G
:c::rust::ts::py::r::spring:

TS is neither a serde nor a validation tool. It only provides type guards in your code.

6 hours ago
empwilli

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.

13 hours ago
steve-wicks

HAHAHA LOL

14 hours ago
x3bla
:j::py:

If you want strict typing... Why are you usin python?

10 hours ago
juklwrochnowy

Wait, can't you already static type any variable and argument if you wish?

10 hours ago
cherrycode420

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 🤔

9 hours ago
juklwrochnowy

I only just started learning python, what does the typing package do?

9 hours ago
cherrycode420

i can't say much because i am not a python guy, but i need to use it at work rn. at least, the typing package provides a more convenient way to write type annotations, with things like Optional compared to MyType | None or other weird stuff

1 minute ago
backfire10z

It isn’t static typing. It has no effect at runtime.

1 hour ago
tehtris
:py::lua::bash::

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.

15 hours ago
Itsthejoker
:py::js:

Mypy is literally the worst. So many hours spent fighting inane and impossible errors

15 hours ago
Not-the-best-name
:py:

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.

15 hours ago
Birnenmacht
:py::c::bash:

and it’s so bloated and slow as well

6 hours ago
CyberWolf755
:cp::unreal:

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

3 hours ago
[deleted]

[deleted]

14 hours ago
skwyckl
:elixir-vertical_4::py::r::js:

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.

12 hours ago
ganjlord

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.

13 hours ago
Wertbon1789

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.

11 hours ago
Darkstar_111

Java people writing Python.

12 hours ago
renrutal

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.

7 hours ago
Ok-Nectarine-2195

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

17 hours ago
TrackLabs

ok LLM

14 hours ago
Commercial-Mud8002

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.

7 hours ago