Libraries
List of dependency injection libraries for Python, sorted by stars:
Tests
dependencies | antidote | diay | dependency_injector | |
---|---|---|---|---|
Easy to use | ✔️ | ✔️ | ✔️ | ❌ |
Good docs | ✔️ | ✔️ | ❌ | ❌ |
Explicit container | ✔️ | ❌ | ❌ | ✔️ |
Type annotation | ❌ | ✔️ | ✔️ | ❌ |
Lazy annotation | ❌ | ✔️ | ✔️ | ❌ |
Name detection | ✔️ | ❌ | ❌ | ❌ |
Function as target | ❌ | ✔️ | ✔️ | ✔️ |
Partial injection | ✔️ | ✔️ | ✔️ | ✔️ |
Overload deps | ✔️ | ✔️ | ✔️ | ❌ |
Deps for deps | ✔️ | ✔️ | ✔️ | ✔️ |
Test description:
- Easy to use -- you don't have to know about some difficult conceptions and write much of code.
- Good docs -- documentation exists and contains many examples and API reference.
- Explicit container -- you define set of dependencies explicitly that helps you to find out which dependencies was used here without debugging.
- Type annotation -- library can detect right dependency by type in annotations.
- Lazy annotation -- library can work with lazy type annotations (defined as string). In Python 4.0 all annotations will be lazy.
- Name detection -- library can detect right dependency by variable name.
- Function as target -- you can inject dependencies into function.
- Partial injection -- you can mix up dependencies with not injected arguments.
- Overload deps -- you can pass your own dependencies to override dependencies in container.
- Deps for deps -- dependencies can be injected into other dependencies.
Usage
See tests dir and docs for libraries for usage examples.
Run tests
pip3 install --user -r requirements.txt
pytest --tb=short