#attrs

New account, so new #introduction. Let's do it again!

I have a
#MastersDegree in #ComputerScience and #ComputerEngineering. I went to #NMU for undergrad and #MSU for my graduate degree. I currently work at #UChicago for the #TMWCenter, which focuses on helping young children acquire language (and therefore other learning skills) faster.

In my spare time, I develop
#OpenSourceSoftware such as
- a
#SphinxDoc extension that embed #Fediverse comments on your page
- a library to talk to
#ManifoldMarkets from native #Python
- a
#PredictionMarket manager using the above
- a
#transpiler from a subset of Python to #OpenStreetMaps's #OverpassQL
- bug fixes to many other projects, including
#mypy, #base58, #attrs, #CPython, & more

I spend a fair bit of my time these days on
#MathResearch, specifically into the #ThueMorse Sequence and its extensions.

I'm also a hobbyist editor on OpenStreetMap.

#Demisexual, #transfem, and happily engaged to my #enby sweetheart.

We have two cats:
#OpheTheLoaf and #MayalaranTheCat (yes, from #StormlightArchive) See here for more on them!

I speak English fluently, Spanish haltingly, and am trying to learn Chinese

#queer #Chicago

Timothée Mazzucotelli :python:pawamoy@fosstodon.org
2024-12-31

How do you generate JSON schemas of your dataclasses' **inputs**? Any third-party library (something else than stdlib's dataclasses) allowing one to do that?

For example, input type is `int | str`, but final/output type is always `int` (coerced). I want to document the input type, not the output type.

#python #pydantic #dataclass #attrs #jsonschema

2024-12-18

Oh dang, my #introduction post is waaay out of date now. Let's do it again!

I have a #MastersDegree in #ComputerScience and #ComputerEngineering. I went to #NMU for undergrad and #MSU for my graduate degree. I currently work at #UChicago for the #TMWCenter, which focuses on helping young children acquire language (and therefore other learning skills) faster.

In my spare time, I develop #OpenSourceSoftware such as

I spend a fair bit of my time these days on #MathResearch, specifically into the #ThueMorse Sequence and its extensions.

I'm also a hobbyist editor on OpenStreetMap.

#Demisexual, #transfem, and happily engaged to my #enby sweetheart.

We have two cats: #OpheTheLoaf and #MayalaranTheCat (yes, from #StormlightArchive)

#queer #Chicago

Two cats are by a sliding glass window. The one towards the top of the frame (named Ophelia) is laying on a heat pad and staring at the second cat. The second cat (named Maya) is towards the bottom of the frame. She is sat on the entry rug with her body poked between the blinds on the window, so that she can look outside.There are two cats in frame, near a very small cat tower. On top of the tower, Ophelia is laying down. Below, in a meercat-like pose, is Maya. She is trying to get a better view of the other cat. They didn't know each other very well at this time.A gray cat, Maya, is laying on the couch. She is curled up such that her belly and paws are all exposed, though her tail is tucked near her feet. She looks peacefully asleepA gray/gray-orange cat is laying on a white blanket. Her name is Ophelia, and she has one eye half open, which is a brilliant green-orange. She is very relaxed. You get the faint impression of a person's legs underneath the blanket
2024-08-13

Every time I read the #Pydantic docs, I come away feeling like I'm the problem because I just don't comprehend the reasoning behind some of their design decisions. Take, for instance, this section from the Settings Management page[1], about changing the settings sources used and their relative priorities:

> If the default order of priority doesn't match your needs, it's possible to change it by overriding the `settings_customise_sources` method of your `Settings`. `settings_customise_sources` takes four callables as arguments and returns any number of callables as a tuple.

... What?

Which callables? Why are there four of them, when I ultimately want to use a number of sources that isn't 4? Why are they callables, when custom sources are implemented as classes? Why can't I just return a set of sources with some sort of explicit priority attached?

I feel like the Pydantic documentation strategy is: "There's probably a thing you want to do, here's a full example of how to do it." That leaves me to enjoy the tasty sauce, without understanding how it was made or how to make it less salty.

In comparison, the documentation for #attrs[2] is a joy to read, dispensing the right amount of knowledge at the right times. It probably helps that the attrs API surface is also not as daunting.

#Python

[1] docs.pydantic.dev/latest/conce
[2] attrs.org/en/stable/overview.h

Dániel Ernő Szabór3ap3rpy
2024-02-06
Tin Tvrtkovićtintvrtkovic
2023-12-19

Another thing I've had to do is overhaul how uapi handles OpenAPI; make it more general.

I think in a couple of releases I'll be able to spin this out into a separate package.

Folks have been asking for jsonschema/openapi stuff for and cattrs for ages.
It's not there yet though.

Stefan Scherfkesscherfke
2023-10-03

@ossronny Support for dataclasses (and ) has landed in gitlab.com/sscherfke/typed-set

Working on it showed me once again while I still prefer over them. 😬

Need to update the Readme and installation instrcution and can than merge it to main.

2023-08-28

First post here 🚨

Recently I published my first blog post on how we used attrs and cattrs to model our API payloads.
Check it out here:

medium.com/klaviyo-engineering

Stefan Scherfkesscherfke
2023-08-06

With this MR (gitlab.com/sscherfke/typed-set), will get its own, built-in converter making optional (but still recommended, because it's faster and more awesome).

But this reduces the list of mandatory requirements.

Next one on my list ist (I’m sorry, @hynek 🙈).

With modern Pythons, TS will than have zero mandatory dependencies (and only tomli on oder Pythons). This should make it more attractive for projects like to adopt it. 🙂

Hynek Schlawackhynek
2023-04-16

Just in time for , here have an attrs 23.1.0: github.com/python-attrs/attrs/

If you're an user and are coming to SLC, come and say hi!

Hynek Schlawackhynek
2023-04-01
Screenshot of https://pepy.tech/project/attrs showing 3 billion total downloads for the attrs PyPI package.
Tim Smithtim@tds.xyz
2023-02-19

One pleasant trick I adopted was using #attrs metadata to describe the structure of the records: github.com/tdsmith/sdif/blob/0

Python type hints on the fields map to the different formatting rules for SDIF field types: github.com/tdsmith/sdif/blob/0

My continued thanks to @hynek for building and maintaining attrs! 🫡

code listing of FileDescription class, available at first link
Tin Tvrtkovićtintvrtkovic
2023-02-08

In 1.0, you can use `Final` attributes in classes and Mypy will know they are frozen instance attributes.

So if you use Mypy, this'll get you *overhead-free* frozen classes, but with a bunch of caveats:
* it doesn't work if the attribute has a default (any default), even like `attrs.field` or `attrs.Factory`
* the class won't be hashable by default

These are tricky to solve. The work continues.

Hynek Schlawackhynek
2023-01-02

-using friends!

Is joblib something y'all use and would be interesting in custom hashing support in like this gentleperson: stackoverflow.com/q/74975393/4 ?

I've never heard of that pkg before but 23M dl/month suggest it's popular. 😅

2022-11-12

It's time for a re-#introduction!

I'm a #MastersStudent in #ComputerScience. In my spare time, I develop #OpenSourceSoftware such as
- a library to talk to #ManifoldMarkets from native #Python
- a #PredictionMarket manager using the above
- a transpiler from a subset of Python to #OpenStreetMaps's OverpassQL
- bug fixes to many other projects, including #mypy, #base58, #attrs, #cpython, and more

I'm also a hobbyist editor on OpenStreetMap.

#Bi, #transfem, and happily dating my enby sweetheart

Olivia AppletonLivInTheLookingGlass
2022-11-02

It's time for a re-!

I'm a in . In my spare time, I develop such as
- a library to talk to from native
- a manager using the above
- a transpiler from a subset of Python to 's OverpassQL
- bug fixes to many other projects, including , , , , and more

I'm also a hobbyist editor on OpenStreetMap.

, , and happily dating my enby sweetheart

Serge Matveenko ⚠️ movedlig@fosstodon.org
2021-01-26

`__attrs_pre_init__` and `__attrs_init__` support is comming to Python Attrs library!

See docs for `attr.s` `init` parameter here attrs.org/en/latest/api.html

@hynek @hynek
#python #attrs

clacke: exhausted pixie dream boy 🇸🇪🇭🇰💙💛clacke@libranet.de
2019-08-15
#attrs are neater and neater the more I learn.

www.attrs.org/

#python
2019-01-10

Using Python's attrs library, I try to instantiate an object and I get a TypeError from the attrs generated __init__. It probably has to do with something stupid like my class being subclassed from 5 or 6... oh wait, I think I figured it out. But in any case, how do I see the generated __init__? Use the inspect module?

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst