]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
fix: use a more generic connection type in {Client,Server}Cursor
authorDenis Laxalde <denis@laxalde.org>
Sun, 15 May 2022 12:28:36 +0000 (14:28 +0200)
committerDenis Laxalde <denis@laxalde.org>
Thu, 19 May 2022 17:42:12 +0000 (19:42 +0200)
This makes them similar to plain Cursor class, i.e. being parametrized
on sync or async connection type, not the row type (which is handled
through the second type variable).

psycopg/psycopg/client_cursor.py
psycopg/psycopg/server_cursor.py

index ee0e46c814283f06e131cc951e364e67e01544f3..bdaa4e127c3159ef83129f382600042e95202b81 100644 (file)
@@ -19,6 +19,7 @@ from ._preparing import Prepare
 from .cursor_async import AsyncCursor
 
 if TYPE_CHECKING:
+    from typing import Any  # noqa: F401
     from .connection import Connection  # noqa: F401
     from .connection_async import AsyncConnection  # noqa: F401
 
@@ -87,11 +88,11 @@ class ClientCursorMixin(BaseCursor[ConnectionType, Row]):
         return (Prepare.NO, b"")
 
 
-class ClientCursor(ClientCursorMixin["Connection[Row]", Row], Cursor[Row]):
+class ClientCursor(ClientCursorMixin["Connection[Any]", Row], Cursor[Row]):
     __module__ = "psycopg"
 
 
 class AsyncClientCursor(
-    ClientCursorMixin["AsyncConnection[Row]", Row], AsyncCursor[Row]
+    ClientCursorMixin["AsyncConnection[Any]", Row], AsyncCursor[Row]
 ):
     __module__ = "psycopg"
index 76e1cb19f8c1a12167a256dd164271452ccf887c..65db17212b9fe40b14b7dbaca5d70d85566ab39b 100644 (file)
@@ -198,7 +198,7 @@ _C = TypeVar("_C", bound="ServerCursor[Any]")
 _AC = TypeVar("_AC", bound="AsyncServerCursor[Any]")
 
 
-class ServerCursor(ServerCursorMixin["Connection[Row]", Row], Cursor[Row]):
+class ServerCursor(ServerCursorMixin["Connection[Any]", Row], Cursor[Row]):
     __module__ = "psycopg"
     __slots__ = ()
 
@@ -338,7 +338,7 @@ class ServerCursor(ServerCursorMixin["Connection[Row]", Row], Cursor[Row]):
 
 
 class AsyncServerCursor(
-    ServerCursorMixin["AsyncConnection[Row]", Row], AsyncCursor[Row]
+    ServerCursorMixin["AsyncConnection[Any]", Row], AsyncCursor[Row]
 ):
     __module__ = "psycopg"
     __slots__ = ()