lagom
lagom copied to clipboard
📦 Autowiring dependency injection container for python 3
This will involve refactoring and hopefully simplifying some internal details of how partials work
TDLR from the zen of python: explicit is better than implicit. So make dependencies explicit in function and constructor signatures.
There are broadly three lifetimes: * Singleton - exists for the life of the container once created. * Invocation level shared - constructed once during a single function call (wrapped...
When using FastAPI, the @context_dependency_definition decorator is not considered for constructing the type if the given type is not injected before other injections in the route definition. Consider the following...
Trying to use the context container to create a "transaction" for the whole "request". Here is some code to give an example: ```python import asyncio import dataclasses from collections.abc import...
``` from lagom import Container class B: def __init__(self, a: 'A') -> None: self.a = A class A: p = 'x' def __init__(self, b: B) -> None: self.b = b...
``` class PromptTemplateRepo(BaseRepo): def __init__(self, *, sa_service: SaService | None = None, should_auto_commit: bool = False): super().__init__(sa_service=sa_service, should_auto_commit=should_auto_commit) ``` ``` repo = agent_store_container()[PromptTemplateRepo] ``` UnresolvableType: Unable to construct dependency of...
Is it possible to use context managers without decorators? https://lagom-di.readthedocs.io/en/latest/clean_up/