We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there any way to pass config dict as **kwargs to my class? There is 2 problem I try to solve:
session_db
None
from dependency_injector import containers, providers class Client: def __init__( self, api_id: int, session_db: str | Path = "some default value", ): self.api_id = api_id self.session_db = session_db class ApplicationContainer(containers.DeclarativeContainer): config = providers.Configuration() my_client = providers.Singleton( Client, config.client.api_id, config.client.session_db, ) container = ApplicationContainer() container.config.from_dict( { "client": { "api_id": "id", }, }, ) my_client = container.my_client() assert my_client.session_db == "some default value"
What I want is something like
class ApplicationContainer(containers.DeclarativeContainer): config = providers.Configuration() my_client = providers.Singleton( Client, **config.client )
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Is there any way to pass config dict as **kwargs to my class?
There is 2 problem I try to solve:
session_db
has a default, which become useless as if not provided in config it will beNone
.What I want is something like
The text was updated successfully, but these errors were encountered: