attrs v17.3.0 Release Notes
Release Date: 2017-11-08 // over 6 years ago-
Backward-incompatible Changes
- Attributes are no longer defined on the class body.
This means that if you define a class
C
with an attributex
, the class will not have an attributex
for introspection. Instead ofC.x
, useattr.fields(C).x
or look atC.__attrs_attrs__
. The old behavior has been deprecated since version 16.1. (#253 <https://github.com/python-attrs/attrs/issues/253>
_)🔄 Changes ^
super()
and__class__
now work with slotted classes on Python 3. (#102 <https://github.com/python-attrs/attrs/issues/102>
,#226 <https://github.com/python-attrs/attrs/issues/226>
,#269 <https://github.com/python-attrs/attrs/issues/269>
,#270 <https://github.com/python-attrs/attrs/issues/270>
,#272 <https://github.com/python-attrs/attrs/issues/272>
_)- Added type argument to
attr.ib()
and correspondingtype
attribute toattr.Attribute
.
This change paves the way for automatic type checking and serialization (though as of this release
attrs
does not make use of it). In Python 3.6 or higher, the value ofattr.Attribute.type
can alternately be set using variable type annotations (seePEP 526 <https://www.python.org/dev/peps/pep-0526/>
). (#151 <https://github.com/python-attrs/attrs/issues/151>
,#214 <https://github.com/python-attrs/attrs/issues/214>
,#215 <https://github.com/python-attrs/attrs/issues/215>
,#239 <https://github.com/python-attrs/attrs/issues/239>
_)- The combination of
str=True
andslots=True
now works on Python 2. (#198 <https://github.com/python-attrs/attrs/issues/198>
_) attr.Factory
is hashable again. (#204 <https://github.com/python-attrs/attrs/issues/204>
_)- Subclasses now can overwrite attribute definitions of their base classes.
That means that you can -- for example -- change the default value for an attribute by redefining it. (
#221 <https://github.com/python-attrs/attrs/issues/221>
,#229 <https://github.com/python-attrs/attrs/issues/229>
)- Added new option auto_attribs to
@attr.s
that allows to collect annotated fields without setting them toattr.ib()
.
Setting a field to an
attr.ib()
is still possible to supply options like validators. Setting it to any other value is treated like it was passed asattr.ib(default=value)
-- passing an instance ofattr.Factory
also works as expected. (#262 <https://github.com/python-attrs/attrs/issues/262>
,#277 <https://github.com/python-attrs/attrs/issues/277>
)- Instances of classes created using
attr.make_class()
can now be pickled. (#282 <https://github.com/python-attrs/attrs/issues/282>
_)