python-dependency-injector
python-dependency-injector copied to clipboard
Dependency injection framework for Python
Hello, We have some function that uses `Closing[Provide["session"]]` to inject the database session to the method. It works well, except if we have any exception raised in the function the...
An issue for aiohttp-pydantic already [opened ](https://github.com/Maillol/aiohttp-pydantic/issues/44). But does anyone know how we can fix it on DI side? (there is no any activity in aiohttp-pydantic repo last months) In...
From the following documentation and sample code: https://python-dependency-injector.ets-labs.org/providers/inject_self.html ```python from dependency_injector import containers, providers class Service: def __init__(self, name: str): self.name = name class ServiceDispatcher: def __init__(self, container: containers.Container): self.container...
I’m trying to setup a direct provider to my db instance. My mongo client is properly initialized and provide a dict-like interface for me to reach my database. I only...
i have used dependency_injector and injecting DynamicContainer. It is working fine on local machine or if i run it with python3 wsgi.py on ubuntu machine. But when running it with...
I use simple Python unit tests. Currently I do not see any way to detect what object is provided within an injected function argument defaulted with `Provide`. **E.g.** Function declaration...
I have the below container for API consumers; ``` python class Consumers(DeclarativeContainer): steam_web_credentials: Dependency[ConfigSteamCredentials] = Dependency( ConfigSteamCredentials) steam_web_consumer: Singleton[SteamWebConsumer] = Singleton(SteamWebConsumer, steam_web_credentials) steam_web_auth = steam_web_consumer.provided.authenticated.call() steam_web_token = steam_web_consumer.provided.authenticated.token # USING...
Im curious if there is a reason that "lazily" loading dependencies is the only way to load any kind of provider (with the exception of `Resources`) I think it makes...
Hello all! Im having a fun time experimenting with this framework, but have found myself stumped on this design issue for a while. In short, if a dependency needs to...
```python from dependency_injector.containers import DeclarativeContainer from dependency_injector.providers import Configuration, Resource, Factory, Singleton ``` app\containers.py:3:0: E0611: No name 'DeclarativeContainer' in module 'dependency_injector.containers' (no-name-in-module) app\containers.py:4:0: E0611: No name 'Configuration' in module 'dependency_injector.providers'...