From 1fe058c7bfabce6fd26fb6534afe8a30d42ba242 Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Sun, 15 May 2022 14:28:36 +0200 Subject: [PATCH] fix: use a more generic connection type in {Client,Server}Cursor 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 | 5 +++-- psycopg/psycopg/server_cursor.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/psycopg/psycopg/client_cursor.py b/psycopg/psycopg/client_cursor.py index ee0e46c81..bdaa4e127 100644 --- a/psycopg/psycopg/client_cursor.py +++ b/psycopg/psycopg/client_cursor.py @@ -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" diff --git a/psycopg/psycopg/server_cursor.py b/psycopg/psycopg/server_cursor.py index 76e1cb19f..65db17212 100644 --- a/psycopg/psycopg/server_cursor.py +++ b/psycopg/psycopg/server_cursor.py @@ -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__ = () -- 2.47.2