diff --git a/src/dishka/dependency_source/make_factory.py b/src/dishka/dependency_source/make_factory.py index d5a97cc9..deb72807 100644 --- a/src/dishka/dependency_source/make_factory.py +++ b/src/dishka/dependency_source/make_factory.py @@ -433,6 +433,11 @@ def make_factory( is_in_class: bool, override: bool, ) -> Factory: + if get_origin(source) is ProvideMultiple: + if provides is None: + provides = source + source = get_args(source)[0] + if is_bare_generic(source): source = source[get_type_vars(source)] # type: ignore[index] diff --git a/tests/unit/container/test_alias.py b/tests/unit/container/test_alias.py index 1c69f614..1fdb615b 100644 --- a/tests/unit/container/test_alias.py +++ b/tests/unit/container/test_alias.py @@ -67,6 +67,24 @@ def test_implicit(): mock.assert_called_once() + +def test_implicit_no_source(): + provider = Provider(scope=Scope.APP) + provider.provide_all(AnyOf[float, str]) + container = make_container(provider) + assert container.get(float) == 0.0 + assert container.get(str) == 0.0 + + + +def test_implicit_all(): + provider = Provider(scope=Scope.APP) + provider.provide_all(AnyOf[float, str]) + container = make_container(provider) + assert container.get(float) == 0.0 + assert container.get(str) == 0.0 + + def test_implicit_generator(): class MyProvider(Provider): value = 0