attrs 17.3.0 released!
hs at ox.cx
Wed Nov 8 13:20:58 EST 2017
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:
... class C:
... x = attr.ib(type=int)
... y: int = attr.ib()
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
... 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(l=, x=1, bar=None)
- 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,
More information about the Python-announce-list