Repository: reagento/dishka

Issue:
Abstract type provider not working.
MRE:

dishka==1.4.0

```py
from dishka import Provider, Scope, provide, make_container
from abc import ABC, abstractmethod


class AbstractFoo(ABC):
    @abstractmethod
    def bar(self) -> None: ...


class SolidFoo(AbstractFoo):
    def bar(self) -> None:
        print('hello')


class MREProvider(Provider):
    @provide(scope=Scope.APP)
    def get_foo_class(self) -> type[AbstractFoo]:
        return SolidFoo

    @provide(scope=Scope.REQUEST)
    def provide_foo(self, foo_cls: type[AbstractFoo]) -> AbstractFoo:
        return foo_cls()


def main() -> None:
    c1 = make_container(MREProvider())
    with c1(scope=Scope.REQUEST) as c2:
        c2.get(AbstractFoo)


main()
```
causes:
```
TypeError: Can't instantiate abstract class AbstractFoo without an implementation for abstract method 'bar'
```
However, if we change scope of type provide to REQUEST, it works:
```
    @provide(scope=Scope.REQUEST)
    def get_foo_class(self) -> type[AbstractFoo]:
        return SolidFoo
```

Downgrading:

dishka==1.2.0 - works OK
dishka==1.3.0 - works OK

Discussion:

Patch:
diff --git a/src/dishka/registry.py b/src/dishka/registry.py
index c7d67b5..fd58d3c 100644
--- a/src/dishka/registry.py
+++ b/src/dishka/registry.py
@@ -14,13 +14,16 @@ from .factory_compiler import compile_factory
 
 
 class Registry:
-    __slots__ = ("scope", "factories", "compiled", "compiled_async")
+    __slots__ = (
+        "scope", "factories", "compiled", "compiled_async", "has_fallback",
+    )
 
-    def __init__(self, scope: BaseScope):
+    def __init__(self, scope: BaseScope, *, has_fallback: bool) -> None:
         self.scope = scope
         self.factories: dict[DependencyKey, Factory] = {}
         self.compiled: dict[DependencyKey, Callable[..., Any]] = {}
         self.compiled_async: dict[DependencyKey, Callable[..., Any]] = {}
+        self.has_fallback = has_fallback
 
     def add_factory(
             self,
@@ -64,7 +67,7 @@ class Registry:
             origin = get_origin(dependency.type_hint)
             if not origin:
                 return None
-            if origin is type:
+            if origin is type and self.has_fallback:
                 return self._get_type_var_factory(dependency)
 
             origin_key = DependencyKey(origin, dependency.component)
@@ -112,10 +115,10 @@ class Registry:
             hint = source_dependency.type_hint
             if isinstance(hint, TypeVar):
                 hint = params_replacement[hint]
-            elif get_origin(hint):
+            elif get_origin(hint) and (type_vars:=get_type_vars(hint)):
                 hint = hint[tuple(
                     params_replacement[param]
-                    for param in get_type_vars(hint)
+                    for param in type_vars
                 )]
             new_dependencies.append(DependencyKey(
                 hint, source_dependency.component,
@@ -125,10 +128,10 @@ class Registry:
             hint = source_dependency.type_hint
             if isinstance(hint, TypeVar):
                 hint = params_replacement[hint]
-            elif get_origin(hint):
+            elif get_origin(hint) and (type_vars:=get_type_vars(hint)):
                 hint = hint[tuple(
                     params_replacement[param]
-                    for param in get_type_vars(hint)
+                    for param in type_vars
                 )]
             new_kw_dependencies[name] = DependencyKey(
                 hint, source_dependency.component,
diff --git a/src/dishka/registry_builder.py b/src/dishka/registry_builder.py
index ccc7526..a314207 100644
--- a/src/dishka/registry_builder.py
+++ b/src/dishka/registry_builder.py
@@ -170,8 +170,9 @@ class RegistryBuilder:
                 self.aliases[provides] = alias
 
     def _init_registries(self) -> None:
+        has_fallback = True
         for scope in self.scopes:
-            registry = Registry(scope)
+            registry = Registry(scope, has_fallback=has_fallback)
             context_var = ContextVariable(
                 provides=DependencyKey(self.container_type, DEFAULT_COMPONENT),
                 scope=scope,
@@ -180,6 +181,7 @@ class RegistryBuilder:
             for component in self.components:
                 registry.add_factory(context_var.as_factory(component))
             self.registries[scope] = registry
+            has_fallback = False
 
     def _process_factory(
             self, provider: BaseProvider, factory: Factory,


Test patch:
diff --git a/tests/unit/container/test_generic.py b/tests/unit/container/test_generic.py
index 79b307f..4b00e59 100644
--- a/tests/unit/container/test_generic.py
+++ b/tests/unit/container/test_generic.py
@@ -207,3 +207,18 @@ def test_passing_type_var_decorator():
     provider.decorate(type_var_decorator)
     container = make_container(provider)
     assert container.get(int) == (int, 1, A(42, y=42))
+
+
+
+def func_with_type(param: type[T], param2: type[int]) -> A[T]:
+    return param, param2
+
+
+def test_provide_type_non_generic():
+    provider = Provider(scope=Scope.APP)
+    provider.provide(func_with_type, scope=Scope.REQUEST)
+    provider.provide(lambda: bool, provides=type[int])
+    container = make_container(provider)
+    with container() as c:
+        assert c.get(A[str]) == (str, bool)
+        assert c.get(A[int]) == (bool, bool)