Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python.announce > #2682

attrs 17.3.0 released!

From Hynek Schlawack <hs@ox.cx>
Newsgroups comp.lang.python.announce
Subject attrs 17.3.0 released!
Date 2017-11-08 19:20 +0100
Message-ID <mailman.105.1510232490.2819.python-announce-list@python.org> (permalink)
References <B54E11F6-8B70-4C0A-96FD-30519AD902FE@ox.cx>

Show all headers | View raw


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

Back to comp.lang.python.announce | Previous | Next | Find similar | Unroll thread


Thread

attrs 17.3.0 released! Hynek Schlawack <hs@ox.cx> - 2017-11-08 19:20 +0100

csiph-web