andi
andi copied to clipboard
Library for annotation-based dependency injection
Currently andi docs suggest this as a build function: ```py def build(plan): instances = {} for fn_or_cls, kwargs_spec in plan: if isinstance(fn_or_cls, CustomBuilder): instances[fn_or_cls.result_class_or_fn] = fn_or_cls.factory(**kwargs_spec.kwargs(instances)) else: instances[fn_or_cls] = fn_or_cls(**kwargs_spec.kwargs(instances))...
e.g. ``` request_or_response_url: Reuse[ResponseUrl] | RequestUrl ``` Should use RequestUrl unless ResponseUrl is also requested separately.
Currently, `andi.plan()` works by passing a function or class. This requires them to have their signatures already established: ```python class Valves: pass class Engine: def __init__(self, valves: Valves): self.valves =...
I'm trying to use [scrapy-po](https://github.com/scrapinghub/scrapy-po/]) – which relies on andi – with a callback provided by `functools.partial` but I'm facing the following traceback. Andi is internally trying to use `typing.get_type_hints`...