Skip to content

Releases: hynek/svcs

23.12.0

09 Aug 14:00
23.12.0
a733a19
Compare
Choose a tag to compare

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

08 Aug 16:02
23.11.0
8b75fd5
Compare
Choose a tag to compare

Changed

  • Factory results of None are now treated like every other result and cached. #22

  • Calling Container.get() on a service that has an async factory now raises a TypeError. #21

Added

  • API reference docs!

  • A huge glossary that should have been a book. #20

23.10.0

07 Aug 07:05
23.10.0
68f13a9
Compare
Choose a tag to compare

Added

  • Proper documentation at https://svcs.hynek.me/!
    I guess it's getting serious.
    #17

  • Pyramid integration.

    Please note that not all integrations will be shipped with svcs proper once it is stable.
    Some will be moved to separate packages and Pyramid is a prime contender for that.

23.9.0

06 Aug 07:00
23.9.0
d7972e6
Compare
Choose a tag to compare

This is a huge release as far as breaking changes go and I hope the last one of such sorts.

There has always been the conundrum imposed by Python typing whether we a) support automatic type-deduction of the services or b) support abstract classes (ABCs, Protocols).

After lots of waffling, I've gone for a compromise: Container.(a)get() are now properly typed as type[T] -> T (for up to 10 services at once 😅). If you want T to be abstract (until Python typing changes its stance), you'll have to use Container.(a)get_abstract(). The nice thing is that this separation serves more people and will be fully backwards-compatible, if we ever don't need it anymore.

Please see https://github.com/hynek/svcs#typing-caveats for more details and a more verbose explanation of the problem if you don't understand what any of the above means.

Full Changelog

Changed

  • Container.get() and Container.aget() now have type hints that only work with concrete classes but allow for type checking without repeating yourself.
    If you want to use abstract classes like typing.Protocol or ABCs, you can use Container.get_abstract() and Container.aget_abstract() instead.

Added

  • Container.get_abstract() and Container.aget_abstract().
    They behave like Container.get() and Container.aget() before.

  • It is now possible to check if a service type is registered with a Registry by using in.

  • It is now possible to check if a service type has a cached instance within a Container by using in.

  • Registry and Container are now also an (async) context managers that call close() / aclose() on exit automatically.

23.8.0

04 Aug 20:19
23.8.0
66fd1fe
Compare
Choose a tag to compare

Added

  • It's now possible to request multiple services at once by passing multiple types to Container.get() and Container.aget().
    #15

23.7.0

02 Aug 14:49
23.7.0
b84a0c9
Compare
Choose a tag to compare

Added

  • Factories now may take a parameter called svcs_container or that is annotated to be svcs.Container.
    In this case the factory will receive the current container as a first positional argument.
    This allows for recursive factories without global state.
    #10

23.6.0

31 Jul 08:16
23.6.0
991e7c5
Compare
Choose a tag to compare

Warning Still in RFC mode!

Changed

  • Renamed Container.forget_service_type() to Container.forget_about().

Fixed

  • svcs.flask.init_app()'s type hints now take into account custom flask.Flask subclasses.

23.5.0

26 Jul 13:07
23.5.0
a3e689e
Compare
Choose a tag to compare

Still, RFC-mode, added registry-level cleanups which allows to clean up pools automatically.

23.4.0

24 Jul 17:03
23.4.0
ffcf6dd
Compare
Choose a tag to compare

The only difference is that we've rebranded ourselves to svcs which is easier to type and leaves back the "registry" baggage.

I'm still open to better names before we go official tho!

23.3.0

20 Jul 12:19
23.3.0
0e1b71b
Compare
Choose a tag to compare

Added

  • Async method Container.aget(). This was necessary for generator-based cleanups. It works with sync factories too, so you can use it universally in async code.
  • Async method ServicePing.aping(). It works with sync factories and pings too, so you can use it universally in async code. #4

Changed

  • Switched the cleanup mechanism from passing a function to allowing the factory to be a generator that yields the resource and can clean up after the yield. Just like Pytest fixtures. #3