Open
Description
hello.
The following code tries to use SubContainer to perform dependency injection into a Service, but this code cannot be executed with the exception "exception: no description".
from dependency_injector import containers, providers
from dependency_injector.wiring import Provide
class Service:
...
class Container(containers.DeclarativeContainer):
sub_container = providers.DependenciesContainer()
class SubContainer(containers.DeclarativeContainer):
service = providers.Factory(Service)
service: Service = Provide[Container.sub_container.service]
if __name__ == "__main__":
container = Container()
container.wire(modules=[__name__])
assert isinstance(service, Service)
How can I perform dependency injection into a SubContainer?
Metadata
Metadata
Assignees
Labels
No labels