Highlights
Mostly typing fixes in this release, but I'm excited that we found a workaround to make functools.cached_property
work with slotted classes! Also, I'm sure there's gonna be fans of the new behavior of __attrs_pre_init__
where it receives all arguments passed to __init__
if it accepts more than self
.
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), FilePreviews (@filepreviews), Daniel Fortunov (@asqui), and Kevin P. Fleming (@kpfleming).
Maintenance Sustainers
Adam Hill (@adamghill), Dan Groshev (@si14), Magnus Watn (@magnuswatn), David Cramer (@dcramer), Moving Content AG (@moving-content), ProteinQure (@ProteinQure), Jesse Snyder (@jessesnyder), Rivo Laks (@rivol), Ionel Cristian Mărieș (@ionelmc), The Westervelt Company (@westerveltco), Philippe Galvan (@PhilippeGalvan), Birk Jernström (@birkjernstrom), Tim Schilling (@tim-schilling), Chris Withers (@cjw296), Christopher Dignam (@chdsbd), Stefan Hagen (@sthagen), Sławomir Ehlert (@slafs), Mostafa Khalil (@khadrawy), Filip Mularczyk (@mukiblejlok), and Mike Fiedler (@miketheman).
Not to forget 6 more amazing humans who chose to be generous but anonymous!
Full Changelog
Changes
- The type annotation for
attrs.resolve_types()
is now correct. #1141 - Type stubs now use
typing.dataclass_transform
to decorate dataclass-like decorators, instead of the non-standard__dataclass_transform__
special form, which is only supported by Pyright. #1158 - Fixed serialization of namedtuple fields using
attrs.asdict/astuple()
withretain_collection_types=True
. #1165 attrs.AttrsInstance
is now atyping.Protocol
in both type hints and code. This allows you to subclass it along with anotherProtocol
. #1172- If attrs detects that
__attrs_pre_init__
accepts more than justself
, it will call it with the same arguments as__init__
was called. This allows you to, for example, pass arguments tosuper().__init__()
. #1187 - Slotted classes now transform
functools.cached_property
decorated methods to support equivalent semantics. #1200 - Added class_body argument to
attrs.make_class()
to provide additional attributes for newly created classes. It is, for example, now possible to attach methods. #1203