Overview of Dependency Injector features
masterDependency Injector is a high-performance dependency injection framework for Python, implemented using Cython. It facilitates the implementation of Inversion of Control (IoC) patterns through several key mechanisms:
- Providers: Tools to assemble objects, including
Factory,Singleton,Callable,Coroutine,Object,List,Dict,Configuration,Resource,Dependency, andSelector. - Containers: Support for both declarative and dynamic containers to consolidate object assembly.
- Wiring: Enables injecting dependencies directly into functions and methods, facilitating integration with frameworks like Django, Flask, Aiohttp, Sanic, and FastAPI.
- Configuration: Supports loading settings from
yaml,ini,jsonfiles,pydanticsettings, environment variables, and dictionaries. - Overriding: Allows replacing any provider with another on the fly, which is useful for testing (e.g., replacing API clients with mocks).
- Resources: Manages initialization and configuration of resources like logging, event loops, or thread pools.
- Asynchronous Support: Built-in support for asynchronous injections.
- Typing: Provides
mypy-friendly typing stubs.