mathstodon.xyz is one of the many independent Mastodon servers you can use to participate in the fediverse.
A Mastodon instance for maths people. We have LaTeX rendering in the web interface!

Server stats:

2.8K
active users

#pydantic

1 post1 participant0 posts today

#pydantic, one of the most downloaded #python library of all times...

crossing billions of total download just recently...

in the recent years...

has changed from one of the most elegant docs to one of the most horrifying and useless documentations ever...

anything you want to find on their pages these days is a "good luck" with a sneaky smear on the face...

truly a garbage if I'm being completely honest.

Continued thread

Un altre descobriment en aquest camí ha estat #Pydantic. Com podia viure programàticament parlant sense Pydantic?
Pydantic és una biblioteca de Python que serveix per validar i gestionar dades amb tipus. Et permet definir models (com classes) on s’especifica el tipus de cada camp, i automàticament valida i converteix les dades rebudes. Integrat a la perfecció amb fastAPI.

Pydantic for data validation and hydration

blog.narf.ssji.net/2025/03/30/

When using Python in any serious way, one quickly encounters Pydantic. While I’ve run into it in many frameworks, up to now, I never took the time to sit down and work out what it was doing, beyond something like “data models and validation based on type annotations”.

I have so far used dataclasses for my data models and data transfer objects (DTO). But it finally happened, and I needed finer validation on the data within my model. So I decided to take Pydantic for a spin myself, and see what it was doing for real.

tl;dr:

Pydantic _is_ data models and validation based on type annotations (amongst other things)

It’s a (almost) drop-in replacement for dataclasses

Type resolution and validation does add one order of magnitude over dataclasses, but it’s quite acceptable as a tradeoff for not having to write any bespoke validation code

Not only can it validate data, but it can also construct nested Pydantic objects, with support for polymorphism.

The pydantic.TypeAdapter exposes some lower-level mechanisms allowing to compose Pydantic behaviours as needed

[…]

Ara millor, la línia de temps "home" necessita un token vàlid però la línia de temps "public" (federada) no.

codeberg.org/spla/appy/commit/

He tingut que crear un nou model #Pydantic per els tuts de la línia de temps federada perquè no han de tenir "favourited", "reblogged", "muted", "bookmarked", "pinned" ni "filtered"

Summary card of repository spla/appy
Codeberg.orghome timeline needs a valid token but public timeline don't need it · 081cf661ccappy - a headless ActivityPub server written with Python and fastAPI.

#Python developerzy: mam model Pydanticowy, który jest tworzony na podstawie danych z pliku projektowego, tworzonego przez użytkownika.
Mam pole, którego użytkownik nie musi podawać, jego default value to "foo". Jaki typ pola podać?
foo_field: str - bo zawsze jest w nim string
foo_field: Optional[str] - co prawda nigdy nie będzie None, ale dzięki temu użytkownik wie, że nie musi podawać wartości w pliku
#tech #it #pydantic #rozbijanieGownaNaAtomy

For many years I have found Flask to be too basic a tool for modern development. But since I create APIs using Flask with Pydantic to validate the input data, some middlewares for parsing and Blueprint to separate the code into modules... I must admit that I am super comfortable, fast and easy to test.
#flask #python #pydantic