API¶
attrs
works by decorating a class using attr.s()
and then optionally defining attributes on the class using attr.ib()
.
Note
When this documentation speaks about “attrs
attributes” it means those attributes that are defined using attr.ib()
in the class body.
What follows is the API explanation, if you’d like a more hands-on introduction, have a look at Examples.
Core¶
Helpers¶
attrs
comes with a bunch of helper methods that make the work with it easier:
attrs
comes with some handy helpers for filtering:
Validators can be globally disabled if you want to run them only in development and tests but not in production because you fear their performance impact:
Validators¶
attrs
comes with some common validators within the attrs.validators
module: