Versions are year-based with a strict backwards compatibility policy. The third digit is only for regressions.
- Don't overwrite
__name__
with__qualname__
forattr.s(slots=True)
classes. #99
- Add
attr.astuple()
that -- similarly toattr.asdict()
-- returns the instance as a tuple. #77 - Converts now work with frozen classes. #76
- Instantiation of
attrs
classes with converters is now significantly faster. #80 - Pickling now works with
__slots__
classes. #81 attr.assoc()
now works with__slots__
classes. #84- The tuple returned by
attr.fields()
now also allows to access theAttribute
instances by name. Yes, we've subclassedtuple
so you don't have to! Thereforeattr.fields(C).x
is equivalent to the deprecatedC.x
and works with__slots__
classes. #88
- All instances where function arguments were called
cl
have been changed to the more Pythoniccls
. Since it was always the first argument, it's doubtful anyone ever called those function with in the keyword form. If so, sorry for any breakage but there's no practical deprecation path to solve this ugly wart.
Accessing
Attribute
instances on class objects is now deprecated and will stop working in 2017. If you need introspection please use the__attrs_attrs__
attribute or theattr.fields()
function that carry them too. In the future, the attributes that are defined on the class body and are usually overwritten in your__init__
method are simply removed after@attr.s
has been applied.This will remove the confusing error message if you write your own
__init__
and forget to initialize some attribute. Instead you will get a straightforwardAttributeError
. In other words: decorated classes will work more like plain Python classes which was alwaysattrs
's goal.The serious business aliases
attr.attributes
andattr.attr
have been deprecated in favor ofattr.attrs
andattr.attrib
which are much more consistent and frankly obvious in hindsight. They will be purged from documentation immediately but there are no plans to actually remove them.
attr.asdict()
'sdict_factory
arguments is now propagated on recursion. #45attr.asdict()
,attr.has()
andattr.fields()
are significantly faster. #48 #51- Add
attr.attrs
andattr.attrib
as a more consistent aliases forattr.s
andattr.ib
. - Add
frozen
option toattr.s
that will make instances best-effort immutable. #60 attr.asdict()
now takesretain_collection_types
as an argument. IfTrue
, it does not convert attributes of typetuple
orset
tolist
. #69
Python 3.3 and 2.6 aren't supported anymore. They may work by chance but any effort to keep them working has ceased.
The last Python 2.6 release was on October 29, 2013 and isn't supported by the CPython core team anymore. Major Python packages like Django and Twisted dropped Python 2.6 a while ago already.
Python 3.3 never had a significant user base and wasn't part of any distribution's LTS release.
__slots__
have arrived! Classes now can automatically be slots-style (and save your precious memory) just by passingslots=True
. #35- Allow the case of initializing attributes that are set to
init=False
. This allows for clean initializer parameter lists while being able to initialize attributes to default values. #32 attr.asdict()
can now produce arbitrary mappings instead of Pythondict
s when provided with adict_factory
argument. #40- Multiple performance improvements.
- Add a
convert
argument toattr.ib
, which allows specifying a function to run on arguments. This allows for simple type conversions, e.g. withattr.ib(convert=int)
. #26 - Speed up object creation when attribute validators are used. #28
- Add
attr.validators.optional
that wraps other validators allowing attributes to beNone
. #16 - Fix multi-level inheritance. #24
- Fix
__repr__
to work for non-redecorated subclasses. #20
Initial release.