Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def register(
self, service, factory=empty, instance=empty, scope=Scope.transient, **kwargs
):
"""
Register a dependency into the container.
Each registration in Punq has a "service", which is the key used for
resolving dependencies, and either an "instance" that implements the
service or a "factory" that understands how to create an instance on
demand.
Examples:
If we have an object that is expensive to construct, or that
wraps a resouce that must not be shared, we might choose to
use a singleton instance.
>>> from punq import Container
>>> container = Container()