Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

python-clean-architecture

Dependency Injection micro-framework

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 Container as 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_component helper, which allows ad-hoc creation of an instance of a dependency, according to its DI context.
  • A Component mixin class or a ComponentMeta metaclass designed to supply a class with capabilities of self-inspection of its DI context.
  • An Inject descriptor 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 inject functional decorator that injects values for all arguments marked with the Inject descriptor. It is a way to supply dependencies via function-wide scope instead of object-wide scope.
  • A scope decorator and Scope enumerable, 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.