Validation

Catch dependency graph errors before startup.

Validation checks registered classes, factories, and injected property methods without constructing service instances.

container = Container()
container.add_singleton(Settings)
container.add_transient(ApiClient)

container.assert_valid()

What validation catches

AnnotationsMissing typesConstructor and factory parameters need resolvable type hints.
GraphMissing servicesRequired dependencies must be registered or optional.
SafetyCyclesRecursive dependency paths are reported before runtime.
PropertiesInjected methodsProperty injection hooks are validated too.

Collect all errors

errors = container.validate()

if errors:
    for error in errors:
        print(error)

Validation does not call constructors or factories. Runtime errors inside service constructors still happen when the service is resolved.