Got #cattrs coverage up. However, it's just statement coverage, not branch coverage; that'll have to wait a while.

Released #TypedSettings 24.5.0 today.

It improves testability of Click CLIs by allowing to lazily load default settings (this is not an issues with argparse CLIs).

It also adds support for the lastest and gratest #cattrs version (thx to @tintvrtkovic <3)

https://typed-settings.readthedocs.io/en/latest/changelog.html#v24-5-0

Changelog - Typed Settings

New #cattrs is out (24.1.0) but I'm too exhausted to do a large thread about it. The changelog is pretty large: https://catt.rs/en/stable/history.html#id1

A couple of my favorite features:

Hook factories can have the converter injected as an argument now. This very simple change makes them much more self contained and more fun to write.

Some converter APIs can be used as decorators now, and will read type hints from the decorated functions. It's a small thing but it adds finesse.

@hynek helped focus the docs!

History - cattrs 24.1.0 documentation

Here's a #Python thing that's been a problem for #cattrs for a long time.

Fundamentally, this is how cattrs works: you give it some data and a type, and it gives you back an instance of that type. That's all well and good until that type is something more complex than a straight-up class. For example, if that type is something like:

- a union (`int | str`)
- a literal
- a protocol
- an ABC (`Sequence`)
- other fancy typing things

it will still work, but it won't type-check.

The moment I know you've all been waiting for with baited breath has arrived; #cattrs 23.2.0 is now out!

See the release notes here: https://github.com/python-attrs/cattrs/releases/tag/v23.2.0

Here's hoping I don't break your stuff, but even if I do you'll learn the value of pinning dependencies so it'll still be to your benefit! That's just how I roll.

#python

Release v23.2.0 · python-attrs/cattrs

23.2.0 (2023-11-15) Welcome to cattrs 23.2.0! Thanks to all our wonderful contributors, this release happens to have the largest changelog so far. Here are some of the noteworthy additions, see bel...

GitHub

A person on the #cattrs issue tracker asked for cattrs to be able to handle unions by iterating through the union members one by one and trying to handle it until one case succeeds.

I think I've seen this approach in other libraries so I tried giving a thoughtful rationale of why I'm not a fan of it: https://github.com/python-attrs/cattrs/issues/423#issuecomment-1699875059

This means cattrs shouldn't be doing this by default. I'm still open to having this on an opt-in basis though, if someone was to contribute it.

#python

Better Union resolution · Issue #423 · python-attrs/cattrs

cattrs version: 23.1.2 Python version: 3.10.6 Operating System: Win 10 Description Right now I'm looking to migrate from dataclass + dacite to attrs + cattrs, but there's a feature in dacite that I...

GitHub
#cattrs depends on the `immutables` package for a subset of its tests. `immutables` 0.19 doesn't support 3.12, `immutables` 0.20 doesn't support 3.7, cattrs supports both. How boned am I?

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:

https://medium.com/klaviyo-engineering/powering-our-apis-using-attr-active-dtos-f88f2177d855

#attrs #cattrs #python #API #software #programming #django

With this MR (https://gitlab.com/sscherfke/typed-settings/-/merge_requests/22), #TypedSettings will get its own, built-in converter making #cattrs 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 #attrs (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 #pytest to adopt it. 🙂

Add a built-in converter and make cattrs optional. (!22) · Merge requests · Stefan Scherfke / typed-settings · GitLab

Typed Settings now supports different converters. It uses cattrs by default (if it is installed) but falls back to the built-in converter automatically if not.

GitLab

After watching Brandt Bucher's PyCon talk on the new 3.11 specializing interpreter, I played around with looking at #cattrs generated functions and how they specialize.

Nothing special there, but I discovered something else. At least on #python 3.11, functions with kw-only params (so, `*` in the arg list before params with defaults) are significantly slower (~10%) than functions with just positional params.