]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
fix: avoid using type variables in typevar bounds
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 27 Sep 2022 08:15:21 +0000 (09:15 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 28 Sep 2022 00:44:53 +0000 (01:44 +0100)
It is not allowed by the specs. Mypy tolerates it, replacing the
argument with Any, according to @erictraut. Pyright reports it as an
error instead.

See #365, microsoft/pyright#3984

psycopg/psycopg/connection.py
psycopg/psycopg/connection_async.py
psycopg/psycopg/copy.py
psycopg/psycopg/cursor.py
psycopg/psycopg/cursor_async.py
psycopg/psycopg/server_cursor.py

index 222cd16883b15c025256eb9ce30bf015b3520b3c..bc15717cda21ef0116042ee89fd763b64defc015 100644 (file)
@@ -655,7 +655,7 @@ class Connection(BaseConnection[Row]):
     server_cursor_factory: Type[ServerCursor[Row]]
     row_factory: RowFactory[Row]
     _pipeline: Optional[Pipeline]
-    _Self = TypeVar("_Self", bound="Connection[Row]")
+    _Self = TypeVar("_Self", bound="Connection[Any]")
 
     def __init__(
         self,
index 89f3b58028b90957718f26a9c6c89f0dbea40d2c..aa02dc0d34b91c4f281df66c5ccd988f46bf4b79 100644 (file)
@@ -52,7 +52,7 @@ class AsyncConnection(BaseConnection[Row]):
     server_cursor_factory: Type[AsyncServerCursor[Row]]
     row_factory: AsyncRowFactory[Row]
     _pipeline: Optional[AsyncPipeline]
-    _Self = TypeVar("_Self", bound="AsyncConnection[Row]")
+    _Self = TypeVar("_Self", bound="AsyncConnection[Any]")
 
     def __init__(
         self,
index cca5e8572d9ba201fb0d47287a1b716e6808b8e1..8f344517cecffb2ddeb1879d02e087da9908ff4f 100644 (file)
@@ -74,7 +74,7 @@ class BaseCopy(Generic[ConnectionType]):
     a file for later use.
     """
 
-    _Self = TypeVar("_Self", bound="BaseCopy[ConnectionType]")
+    _Self = TypeVar("_Self", bound="BaseCopy[Any]")
 
     formatter: "Formatter"
 
index 83b4536e7555dffa647c37734518e01ef2a62363..70eebfbbac78b65a236290fb4db62fef0e1aa82a 100644 (file)
@@ -650,7 +650,7 @@ class BaseCursor(Generic[ConnectionType, Row]):
 class Cursor(BaseCursor["Connection[Any]", Row]):
     __module__ = "psycopg"
     __slots__ = ()
-    _Self = TypeVar("_Self", bound="Cursor[Row]")
+    _Self = TypeVar("_Self", bound="Cursor[Any]")
 
     @overload
     def __init__(self: "Cursor[Row]", connection: "Connection[Row]"):
index 0632940d6ca41cf9caeeb4bc276777975086f4a7..8aa7f71d2d3a9d460115362a6a8ac944826f2e78 100644 (file)
@@ -24,7 +24,7 @@ if TYPE_CHECKING:
 class AsyncCursor(BaseCursor["AsyncConnection[Any]", Row]):
     __module__ = "psycopg"
     __slots__ = ()
-    _Self = TypeVar("_Self", bound="AsyncCursor[Row]")
+    _Self = TypeVar("_Self", bound="AsyncCursor[Any]")
 
     @overload
     def __init__(self: "AsyncCursor[Row]", connection: "AsyncConnection[Row]"):
index 16f11555186488f6922aa5c7ac1677ad319c851f..3a12b5e473174674decd86418479d9ef1ac76b22 100644 (file)
@@ -198,7 +198,7 @@ class ServerCursorMixin(BaseCursor[ConnectionType, Row]):
 class ServerCursor(ServerCursorMixin["Connection[Any]", Row], Cursor[Row]):
     __module__ = "psycopg"
     __slots__ = ()
-    _Self = TypeVar("_Self", bound="ServerCursor[Row]")
+    _Self = TypeVar("_Self", bound="ServerCursor[Any]")
 
     @overload
     def __init__(
@@ -340,7 +340,7 @@ class AsyncServerCursor(
 ):
     __module__ = "psycopg"
     __slots__ = ()
-    _Self = TypeVar("_Self", bound="AsyncServerCursor[Row]")
+    _Self = TypeVar("_Self", bound="AsyncServerCursor[Any]")
 
     @overload
     def __init__(