diff --git a/rodi/__init__.py b/rodi/__init__.py index 5dd0145..ee30708 100644 --- a/rodi/__init__.py +++ b/rodi/__init__.py @@ -746,6 +746,13 @@ def get( scope = ActivationScope(self) resolver = self._map.get(desired_type) + if not resolver: + cls_name = class_name(desired_type) + resolver = ( + self._map.get(cls_name) + or self._map.get(cls_name.lower()) + or self._map.get(to_standard_param_name(cls_name)) + ) scoped_service = scope.scoped_services.get(desired_type) if scope else None if not resolver and not scoped_service: diff --git a/tests/test_services.py b/tests/test_services.py index 2e67f88..bdd3fe3 100644 --- a/tests/test_services.py +++ b/tests/test_services.py @@ -713,6 +713,9 @@ def resolve_derived_class(_) -> DerivedClass: assert isinstance(u, UsingAliasByType) assert isinstance(u.example, DerivedClass) + b = provider.get(BaseClass) + assert isinstance(b, DerivedClass) + def test_get_service_by_name_or_alias(): container = arrange_cats_example()