python-dependency-injector/examples/containers/check_dependencies.py

16 lines
428 B
Python
Raw Normal View History

"""Container dependencies check example."""
from dependency_injector import containers, providers
class Container(containers.DeclarativeContainer):
service1 = providers.Dependency()
service2 = providers.Dependency()
2021-09-30 22:16:17 +03:00
if __name__ == "__main__":
container = Container()
container.check_dependencies() # <-- raises error:
# Container has undefined dependencies: "Container.service1", "Container.service2"