attrs
attrs copied to clipboard
Python Classes Without Boilerplate
This may be by design, but I was hopeful it would work. When an attribute is set during init, `on_setattr` does not seem to apply, but it does after instantiation....
I'd like to move the discussion from [converter decorator PR](https://github.com/python-attrs/attrs/pull/404) to this issue. I think converters are semantically closer to `on_setattr` and `validator` than `default`. E.g. `attr.ib(converter=...)` allows you to...
Hi, I'm working on a project where it's useful for an attribute to refer to the current class. Currently, I'm using something like: ```python from __future__ import annotations # Needed...
Seems like `attr.s`-level `on_setattr` is applied to all attributes including inherited, but doesn't become a part of `Attribute` definition (to save memory in `sa_attrs` dictionary, as far as I understand):...
I have a code similar to the following, that relies very heavily on mypy for correctness: ```python import attr class X: """ Some other class from the code """ class...
A while ago I created https://github.com/bloomberg/attrs-strict a library to help with runtime validation of attrs classes. The way it currently works is you need to "enable" it per attribute in...
I am using attrs to manage the configuration of a database system. I was hoping to use `set_run_validators` to temporarily disable validation during a multi-step evolution of a large data...
I don’t know how far this is aspirational, but https://github.com/python/mypy/issues/3916 gives me some hope?
This has been proposed and discussed in https://github.com/python-attrs/attrs/issues/215, as a possible use case for the newly added `type` argument to `attr.ib()` #239 quoting @hynek https://github.com/python-attrs/attrs/issues/215#issuecomment-347529479 > a good first step...
So data classes have the concept of [init-only variables](https://www.python.org/dev/peps/pep-0557/#init-only-variables): ```python @dataclass class C: i: int j: int = None database: InitVar[DatabaseType] = None def __post_init__(self, database): if self.j is None...