This package contains a micro-framework that serves as an implementation of Dependency Injection pattern for the rest of python-clean-architecture library. It is composed of:
- A
Containeras a central repository of DI definitions and their constructors. The Container isn't expected to be either singleton, global nor static. On the other side, every dependant has to have the Container supplied either by a helper function or by the injection process. - A
create_componenthelper, which allows ad-hoc creation of an instance of a dependency, according to its DI context. - A
Componentmixin class or aComponentMetametaclass designed to supply a class with capabilities of self-inspection of its DI context. - An
Injectdescriptor that knows how to get a dependency instance when it's needed. Alternatively, it marks an argument of a function as a place to inject the dependency instance. - An
injectfunctional decorator that injects values for all arguments marked with theInjectdescriptor. It is a way to supply dependencies via function-wide scope instead of object-wide scope. - A
scopedecorator andScopeenumerable, which describe how often an instance should be created.
This library has potential to be extracted as an independent library in an undefined future when its API reaches stability.