Svcs

Latest version: v24.1.0

Safety actively analyzes 638437 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 2 of 4

23.16.0

Added

- *enter* keyword argument to all `register_(value|factory)()`. It prevents *svcs* from entering context managers if the factory returns one. This is useful for context managers like database transactions that you want to start manually.

- Services acquired using `aget()` now also can receive the current container if they take one argument that is named `svcs_container` or that is annotated as being `svcs.Container` and has any name.

23.15.0

Added

- A `ResourceWarning` is now raised when a container or a registry are garbage-collected with pending cleanups.

Changed

- Cleanups for services are internally context managers now. For your convenience, if you pass an (async) generator function for a factory, the registry will automatically wrap it for you into an (async) context manager. [\92](https://github.com/hynek/svcs/pull/29)

- Pyramid: `svcs.pyramid.get()` now takes a Pyramid request as the first argument. `svcs.pyramid.get_pings()` also doesn't look at thread locals anymore. If you still want to use thread locals, you can use `svcs.pyramid.from_svcs(None)` to obtain the currently active container.

- Flask: `replace_(value|factory)()` is now called `overwrite_(value|factory())` to be consistent with the docs lingo. They also completely reset the instantiation cache now (practically speaking: they close the container).

Removed

- `svcs.Container.forget_about()`. It doesn't make any sense in a world of recursive dependencies. Just reset the container using `svcs.Container.(a)close()`.

23.14.0

Added

- aiohttp: missing `aget_abstract()` function.
- pyramid: missing `get_pings()` function.

23.13.0

[AIOHTTP](https://docs.aiohttp.org/) integration has landed!

23.12.0

Added

- *svcs* now logs registrations at debug level along with a stacktrace. So if you ever get confused where your factories are coming from, set the log level to debug and trace your registrations!

Changed

- Ooof. It's obvious in hindsight, but accessing anything directly on a request object like in the `request.svcs.get()` examples erases type information and everything becomes a big soup of `Any`.

Therefore, we've added a new "best practice" for integrations to have a `svcs_from()` function that extracts containers from request objects (or from thread locals in the case of Flask).

23.11.0

Changed

- Factory results of None are now treated like every other result and cached. [\22](https://github.com/hynek/svcs/pull/22)

- Calling `Container.get()` on a service that has an async factory now raises a `TypeError`. [\21](https://github.com/hynek/svcs/pull/21)

Added

- API reference docs!

- A **huge** [glossary](https://svcs.hynek.me/en/stable/glossary.html) that should have been a book. [\#20](https://github.com/hynek/svcs/pull/20)

Page 2 of 4

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.