Repository: reagento/dishka

Issue:
SqlAlchemy sessionmaker resolve failed
```python
AsyncSessionMaker = async_sessionmaker

class DbProvider(Provider):
    def __init__(self, connection_string: str | AnyUrl, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)
        self.connection_string = str(connection_string)

    @provide(scope=Scope.APP)
    async def get_engine(self) -> AsyncEngine:
        dsn = self.connection_string.replace("postgresql", "postgresql+asyncpg")
        return create_async_engine(dsn)

    @provide(scope=Scope.APP)
    async def get_sessionmaker(self, engine: AsyncEngine) -> AsyncSessionMaker:
        return async_sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)

    @provide(scope=Scope.REQUEST)
    async def get_db_session(self, sessionmaker: AsyncSessionMaker) -> AsyncSession:
        return await get_or_create_db_session(sessionmaker)
```

```shell
dishka.exceptions.NoFactoryError: Cannot find factory for 
DependencyKey(type_hint=<class 'sqlalchemy.ext.asyncio.session.async_sessionmaker'>, component='')
requested by DependencyKey(type_hint=<class 'sqlalchemy.ext.asyncio.session.AsyncSession'>, component=''). 
It is missing or has invalid scope.```

Discussion:

Patch:
diff --git a/src/dishka/registry.py b/src/dishka/registry.py
index 7f9ff0e..db801e7 100644
--- a/src/dishka/registry.py
+++ b/src/dishka/registry.py
@@ -19,10 +19,10 @@ class Registry:
     def add_factory(self, factory: Factory):
         if is_generic(factory.provides.type_hint):
             origin = get_origin(factory.provides.type_hint)
-            origin_key = DependencyKey(origin, factory.provides.component)
-            self._factories[origin_key] = factory
-        else:
-            self._factories[factory.provides] = factory
+            if origin:
+                origin_key = DependencyKey(origin, factory.provides.component)
+                self._factories[origin_key] = factory
+        self._factories[factory.provides] = factory
 
     def get_factory(self, dependency: DependencyKey) -> Factory | None:
         try:


Test patch:
diff --git a/tests/unit/container/test_generic.py b/tests/unit/container/test_generic.py
index 68da0bb..054c06c 100644
--- a/tests/unit/container/test_generic.py
+++ b/tests/unit/container/test_generic.py
@@ -83,6 +83,20 @@ def test_generic_class():
     assert a.x == 42
 
 
+def test_bare_generic_method():
+    class MyProvider(Provider):
+        scope = Scope.APP
+
+        @provide
+        def a(self) -> A:
+            return A(42)
+
+    container = make_container(MyProvider())
+    a = container.get(A)
+    assert isinstance(a, A)
+    assert a.x == 42
+
+
 def test_generic_func():
     class MyProvider(Provider):
         scope = Scope.APP