Skip to content

23.21.0

Compare
Choose a tag to compare
@hynek hynek released this 21 Nov 15:35
· 113 commits to main since this release
23.21.0
2d119dc

Highlights

The main feature of this release are container-local registries that allow you to define factories that are only valid for a container. For example, based on request metadata! Check out the docs for details.

There's one minor backward-incompatible change regarding the handling of values and context managers – please refer to #50 for the reasons.

Finally there's a bunch of fixes around typing.

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), and Mostafa Khalil (@khadrawy).

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

Full Changelog

Changed

  • Backwards-Incompatible: Since multiple people have been bit by the enter=True default for Registry.register_value(), and it's very early in svcs life, we're changing the default to enter=False for all versions of register_value().

    This means that you have to explicitly opt-in to context manager behavior which makes a lot more sense for singletons like connection pools which are the most common candidates for registered values.

    (The irony of shipping a backwards-incompatible change in the release directly following the adoption of a backwards-compatibility policy not lost on me.) #50 #51

Added

  • Container-local registries! Sometimes it's useful to bind a value or factory only to a container. For example, request metadata or authentication information.

    You can now achieve that with svcs.Container.register_local_factory() and svcs.Container.register_local_value(). Once something local is registered, a registry is transparently created and it takes precedence over the global one when a service is requested. The local registry is closed together with the container. #56

  • Flask: svcs.flask.registry which is a werkzeug.local.LocalProxy for the currently active registry on flask.current_app.

Fixed

  • We've stopped rewriting the public names of our objects and typing.get_type_hints() now works on them as expected for Python 3.10 and later. #52 #53

  • The detection of container arguments in svcs.Registry() when using string-based type annotations is more robust now. #55