]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
refactor: use Self to represent the return from `BaseConnection._connect_gen()`
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 3 Jan 2024 02:38:19 +0000 (03:38 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 3 Jan 2024 11:04:03 +0000 (12:04 +0100)
psycopg/psycopg/connection.py

index 163e9b8651ed3aee65e8aab160fefa089f8f6e9e..ef49d0e88b5875c748377ee2efefdf48a4d3ac40 100644 (file)
@@ -20,7 +20,7 @@ from . import pq
 from . import errors as e
 from . import waiting
 from . import postgres
-from .abc import AdaptContext, ConnectionType, Params, Query, RV
+from .abc import AdaptContext, Params, Query, RV
 from .abc import PQGen, PQGenConn
 from .sql import Composable, SQL
 from ._tpc import Xid
@@ -430,10 +430,7 @@ class BaseConnection(Generic[Row]):
     # should have a lock and hold it before calling and consuming them.
 
     @classmethod
-    def _connect_gen(
-        cls: Type[ConnectionType],
-        conninfo: str = "",
-    ) -> PQGenConn[ConnectionType]:
+    def _connect_gen(cls, conninfo: str = "") -> PQGenConn[Self]:
         """Generator to connect to the database and create a new instance."""
         pgconn = yield from connect(conninfo)
         conn = cls(pgconn)