Check container dependenciesΒΆ

To check container dependencies use method .check_dependencies().

from dependency_injector import containers, providers


class Container(containers.DeclarativeContainer):

    service1 = providers.Dependency()
    service2 = providers.Dependency()


if __name__ == "__main__":
    container = Container()
    container.check_dependencies()  # <-- raises error:
    # Container has undefined dependencies: "Container.service1", "Container.service2"

Method .check_dependencies() raises an error if container has any undefined dependencies. If all dependencies are provided or have defaults, no error is raised.

See also: Dependency provider.