Key featuresΒΆ
Key features of the Dependency Injector
:
Providers. Provides
Factory
,Singleton
,Callable
,Coroutine
,Object
,List
,Dict
,Configuration
,Resource
,Dependency
, andSelector
providers that help assemble your objects. See Providers.Overriding. Can override any provider by another provider on the fly. This helps in testing and configuring dev/stage environment to replace API clients with stubs etc. See Provider overriding.
Configuration. Reads configuration from
yaml
,ini
, andjson
files,pydantic
settings, environment variables, and dictionaries. See Configuration provider.Resources. Helps with initialization and configuring of logging, event loop, thread or process pool, etc. Can be used for per-function execution scope in tandem with wiring. See Resource provider.
Containers. Provides declarative and dynamic containers. See Containers.
Wiring. Injects dependencies into functions and methods. Helps integrate with other frameworks: Django, Flask, Aiohttp, Sanic, FastAPI, etc. See Wiring.
Asynchronous. Supports asynchronous injections. See Asynchronous injections.
Typing. Provides typing stubs,
mypy
-friendly. See Typing and mypy.Performance. Fast. Written in
Cython
.Maturity. Mature and production-ready. Well-tested, documented, and supported.
The framework stands on the PEP20 (The Zen of Python) principle:
Explicit is better than implicit
You need to specify how to assemble and where to inject the dependencies explicitly.
The power of the framework is in its simplicity.
Dependency Injector
is a simple tool for the powerful concept.