[Python-announce] attrs 22.3.0

Skip to first unread message

Hynek Schlawack

Dec 21, 2022, 5:29:33 AM12/21/22
I’m happy to announce a new release of attrs!

attrs is the direct ancestor of – and the inspiration for – dataclasses in the standard library and remains the more powerful toolkit for creating regular classes without getting bogged down with writing repetitive boilerplate code: <https://www.attrs.org/>


It's been a lot busier than the changelog indicates, but a lot of the work happened under the hood (like some impressive performance improvements). But we've got still one big new feature that's are worthy the holidays:

Fields now have an alias argument that allows you to set the field's name in the generated __init__ method. This is especially useful for those who aren't fans of attrs's behavior of stripping underscores from private attribute names.

Special Thanks

This release would not be possible without my generous sponsors! Thank you to all of you making sustainable maintenance possible! If you would like to join them, go to https://github.com/sponsors/hynek and check out the sweet perks!

Above and Beyond

Variomedia AG (@variomedia), Tidelift (@tidelift), Sentry (@getsentry), HiredScore (@HiredScore), FilePreviews (@filepreviews), and Daniel Fortunov (@asqui).

Maintenance Sustainers

@rzijp, Adam Hill (@adamghill), Dan Groshev (@si14), Tamir Bahar (@tmr232), Adi Roiban (@adiroiban), Magnus Watn (@magnuswatn), David Cramer (@dcramer), Moving Content AG (@moving-content), Stein Magnus Jodal (@jodal), Iwan Aucamp (@aucampia), ProteinQure (@ProteinQure), Jesse Snyder (@jessesnyder), Rivo Laks (@rivol), Thomas Ballinger (@thomasballinger), @medecau, Ionel Cristian Mărieș (@ionelmc), The Westervelt Company (@westerveltco), Philippe Galvan (@PhilippeGalvan), Birk Jernström (@birkjernstrom), Jannis Leidel (@jezdez), Tim Schilling (@tim-schilling), Chris Withers (@cjw296), and Christopher Dignam (@chdsbd).

Not to forget 2 more amazing humans who chose to be generous but anonymous!

Full Changelog

Backwards-incompatible Changes

- Python 3.5 is not supported anymore. #988


- Python 3.6 is now deprecated and support will be removed in the next release. #1017


- attrs.field() now supports an alias option for explicit __init__ argument names.

Get __init__ signatures matching any taste, peculiar or plain! The PEP 681 compatible alias option can be use to override private attribute name mangling, or add other arbitrary field argument name overrides. #950

- attrs.NOTHING is now an enum value, making it possible to use with e.g. typing.Literal. #983

- Added missing re-import of attr.AttrsInstance to the attrs namespace. #987

- Fix slight performance regression in classes with custom __setattr__ and speedup even more. #991

- Class-creation performance improvements by switching performance-sensitive templating operations to f-strings.

You can expect an improvement of about 5% -- even for very simple classes. #995

- attrs.has() is now a TypeGuard for AttrsInstance. That means that type checkers know a class is an instance of an attrs class if you check it using attrs.has() (or attr.has()) first. #997

- Made attrs.AttrsInstance stub available at runtime and fixed type errors related to the usage of attrs.AttrsInstance in Pyright. #999

- On Python 3.10 and later, call abc.update_abstractmethods() on dict classes after creation. This improves the detection of abstractness. #1001

- attrs's pickling methods now use dicts instead of tuples. That is safer and more robust across different versions of a class. #1009

- Added attrs.validators.not_(wrapped_validator) to logically invert wrapped_validator by accepting only values where wrapped_validator rejects the value with a ValueError or TypeError (by default, exception types configurable). #1010

- The type stubs for attrs.cmp_using() now have default values. #1027

- To conform with PEP 681, attr.s() and attrs.define() now accept unsafe_hash in addition to hash. #1065

Reply all
Reply to author
0 new messages