From b882c7cdf3c6c02ce8e151fd686b75776ec263bd Mon Sep 17 00:00:00 2001 From: Roman Mogylatov Date: Thu, 25 Feb 2021 09:45:07 -0500 Subject: [PATCH] Prototype inline injections --- src/dependency_injector/schema.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/dependency_injector/schema.py b/src/dependency_injector/schema.py index 3b27c6d1..b307775e 100644 --- a/src/dependency_injector/schema.py +++ b/src/dependency_injector/schema.py @@ -64,6 +64,8 @@ def _setup_injections( if isinstance(arg, str): injection = _resolve_provider(container, arg) + # TODO: add inline injections + if not injection: injection = arg @@ -79,6 +81,19 @@ def _setup_injections( if isinstance(arg, str): injection = _resolve_provider(container, arg) + # TODO: refactoring + if isinstance(arg, dict): + provider_args = [] + provider_type = _get_provider_cls(arg.get('provider')) + provides = arg.get('provides') + if provides: + provides = _import_string(provides) + if provides: + provider_args.append(provides) + for provider_arg in arg.get('args', []): + provider_args.append(_resolve_provider(container, provider_arg)) + injection = provider_type(*provider_args) + if not injection: injection = arg