attrs
attrs copied to clipboard
Python Classes Without Boilerplate
# Summary Spike implementation for #945. Goals: - [ ] This is silent no-op for "normal" users of `attrs` not using `alias`. Libraries building on `attrs` *may* use `alias` to...
I've got a few cases where I require a singleton object in my code and was wondering if there's an accepted way to create a singleton with attrs support for...
The following Python 3.10 code fails. ```python from __future__ import annotations import attr @attr.s(auto_attribs=True, slots=False) class FloatValue: float: float = None @attr.s(auto_attribs=True, slots=True) class FloatValueSlots: float: float = None attr.resolve_types(FloatValue)...
[PEP681](https://peps.python.org/pep-0681/) introduces an optional `alias` parameter to field descriptors, which specifies an alternative `__init__` name for the member. This is not implemented in dataclasses, but is [implemented in pydantic](https://pydantic-docs.helpmanual.io/usage/schema/#field-customization). It...
The case that I ran into was that I needed to rename a variable but I still would like to support the old JSON that used the old name. Basically,...
Currently it's not possible to access the current instance in a converter, except you use decorators. I currently define converters automatically based on their type with the `field_transformer` hook, unfortunately...
Sorry for opening the same thread in two different repositories, I did my research but couldn't find a working solution. I think this should be a common use case and...
I've had cases where it's nice to be able to compose the standard validators to do what I need without needing to write a custom function. It generally ends up...
Thanks for maintaining attrs 🙂 I was hoping to start using the newer syntax in a project, but ran into a tiny issue: ### Code sample ```python import attr @attr.s...
Just stumbled across an interesting issue. The `kw_only` flag seems to break pickling of objects. E.g.: ```python import attr import pickle @attr.s(auto_exc=True, kw_only=False) class Positional(Exception): field: int = attr.ib() @attr.s(slots=False,...