Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
>>> class DataAccessLayer:
... pass
...
>>> class SqlAlchemyDataAccessLayer(DataAccessLayer):
... def __init__(self, engine: SQLAlchemy.Engine):
... pass
...
>>> container.register(
... DataAccessLayer,
... instance=SqlAlchemyDataAccessLayer(create_engine("sqlite:///"))
... )
"""
self.__registrations[service].append(
Registration(service, Scope.singleton, lambda: instance, {}, {})
)
for k, v in registration.needs.items()
if k != "return" and k not in registration.args and k not in resolution_args
}
args.update(registration.args)
target_args = inspect.getfullargspec(registration.builder).args
if "self" in target_args:
target_args.remove("self")
condensed_resolution_args = {
key: resolution_args[key] for key in resolution_args if key in target_args
}
args.update(condensed_resolution_args or {})
result = registration.builder(**args)
if registration.scope == Scope.singleton:
self._singletons[registration.service] = result
context[registration.service] = result
return result