How ets-labs/python-dependency-injector works
Dependency Injector is a Python dependency-injection framework. Developers declare providers and containers, configure dependencies and overrides, then resolve assembled objects directly or wire them into application functions; resources support managed lifecycle and async injection. The graph includes README capabilities even where implementation excerpts are absent. Relationships between core provider/container internals are therefore shown only as unverified dashed links; sampled wiring/schema and extension behavior has stronger evidence.
Main entry points: providers.pyx Provider assembly · wiring.py Function and method wiring · containers.pyx Declarative and dynamic containers · schema.py Schema processing
Components 13
Assembly and providers
- Provider assembly
src/dependency_injector/providers.pyx - Declarative and dynamic containers
src/dependency_injector/containers.pyx - Schema processing
src/dependency_injector/schema.py
Configuration and lifecycle
- Configuration providers
src/dependency_injector/providers.pyx - Resource lifecycle
src/dependency_injector/resources.py - Async providers
src/dependency_injector/providers.pyx
Injection and integration
- Function and method wiring
src/dependency_injector/wiring.py - Framework adapters
src/dependency_injector/ext
Runtime foundations
- Framework errors
src/dependency_injector/errors.py - Typing interfaces
src/dependency_injector/providers.pyi
Other components
- Application developer
- Application functions
- Application dependencies
Connections 16
- Application developer → Declarative and dynamic containers: declares providers
README.rst - Application developer → Configuration providers: loads settings
README.rst - Application developer → Function and method wiring: marks injection
README.rst - Declarative and dynamic containers → Provider assembly: holds providers
- Schema processing → Declarative and dynamic containers: builds dynamic
src/dependency_injector/schema.py - Schema processing → Provider assembly: constructs providers
src/dependency_injector/schema.py - Configuration providers → Application dependencies: reads settings
- Provider assembly → Application dependencies: assembles objects
- Resource lifecycle → Application dependencies: initializes resources
- Async providers → Application functions: injects asynchronously
- Function and method wiring → Provider assembly: resolves markers
src/dependency_injector/wiring.py - Function and method wiring → Application functions: patches callables
src/dependency_injector/wiring.py - Framework adapters → Provider assembly: wraps providers
src/dependency_injector/ext/flask.py - Framework adapters → Application functions: adapts views
src/dependency_injector/ext/aiohttp.py - Provider assembly → Framework errors: raises errors
- Typing interfaces → Provider assembly: describes API