attrs
attrs copied to clipboard
Python Classes Without Boilerplate
Hi! I am trying to add multiple validators to a field, which works fine as long as they are both from the `attrs` library or both written by me. When...
This is something for us to consider, and it's come up on the typing mailing list a few times. A _Pick type_ is a TypeScript thing. You take an existing...
I played around and found out that `attrs.astuple` is quite slow in comparison to using `operator.attrgetter` with all the field names. Maybe the performance of `attrs.astuple(recurse=False)` can be improved, benefiting...
How to initialize an instance where all fields are default values? I don't want to add a default value to each field, and I want each field to automatically get...
I was getting the ``` No mandatory attributes allowed after an attribute with a default value or factory. ``` error message related to issues #38 and #93. I had been...
Hello, I have been recently working with the evolve function in attrs and noticed some performance issues which I believe could be improved. Here is an example I tried: ```...
At first, thank for the great and inspiring package! But let me explain my question: ``` def before(instance, attrib, new_value): print(f'before: {attrib.name}={new_value!r}') return new_value def after(instance, attrib, new_value): print(f'after: {attrib.name}={new_value!r}')...
Attrs does some checks on fields like no defaulted fields coming before non-defaulted fields before running custom field transformers. This is a problem when a field transformer intends to modify...
I noticed that functions like `attr.has, attr.fields, attr.fields_dict` doesn't work as i expected when i pass in class with generic type defined: ```from typing import TypeVar, Generic, Mapping, Sequence from...
This PR enables other libraries to define their own Attribute classes (replacing attrs.Attribute), and hence to define their own `fields()` function. _Why does this need to be in attrs?_ Because...