Hi everyone,

I’m very excited to announce the 17.3.0 release of attrs 
<http://www.attrs.org/>, 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:

```pycon
>>> @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:

```pycon
>>> 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: 
<http://www.attrs.org/en/stable/changelog.html>
Get it from PyPI: <https://pypi.org/project/attrs/>

For the attrs team,
Hynek Schlawack
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

        Support the Python Software Foundation:
        http://www.python.org/psf/donations/

Reply via email to