Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python.announce > #2682 > unrolled thread
| Started by | Hynek Schlawack <hs@ox.cx> |
|---|---|
| First post | 2017-11-08 19:20 +0100 |
| Last post | 2017-11-08 19:20 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python.announce
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
attrs 17.3.0 released! Hynek Schlawack <hs@ox.cx> - 2017-11-08 19:20 +0100
| From | Hynek Schlawack <hs@ox.cx> |
|---|---|
| Date | 2017-11-08 19:20 +0100 |
| Subject | attrs 17.3.0 released! |
| Message-ID | <mailman.105.1510232490.2819.python-announce-list@python.org> |
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 top | Article view | comp.lang.python.announce
csiph-web