attrs 17.3.0 released!

Hynek Schlawack hs at
Wed Nov 8 13:20:58 EST 2017

Hi everyone,

I’m very excited to announce the 17.3.0 release of attrs <>, the package that will make you love writing classes again!

A lot has happened under the hood but the main feature we’d like to point out is first-class support for types including PEP 526-style class variable annotations:

>>> @attr.s
... class C:
...     x = attr.ib(type=int)
...     y: int = attr.ib()
>>> attr.fields(C).x.type
<class 'int'>
>>> attr.fields(C).y.type
<class 'int'>

And if you’re OK with annotating *all* attributes, you can drop the `attr.ib()` completely with the new `auto_attribs` option.  Anything that is assigned to the attributes and isn’t an `attr.ib` is used as a default value:

>>> import typing
>>> @attr.s(auto_attribs=True)
... class AutoC:
...     cls_var: typing.ClassVar[int] = 5  # this one is ignored
...     l: typing.List[int] = attr.Factory(list)
...     x: int = 1
...     bar: typing.Any = None
>>> AutoC()
AutoC(l=[], x=1, bar=None)

Please note:

- This feature works with Python 3.6 and later only.
- The type information is currently *not* used by attrs itself, but it allows you to write advanced validators and serializers.

Check out the changelog for all changes: <>
Get it from PyPI: <>

For the attrs team,
Hynek Schlawack

More information about the Python-announce-list mailing list