From 6345e80400149fadbd59d09cabb6a4e2e5e6a2b2 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Wed, 3 Jan 2024 03:38:19 +0100 Subject: [PATCH] refactor: use Self to represent the return from `BaseConnection._connect_gen()` --- psycopg/psycopg/connection.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/psycopg/psycopg/connection.py b/psycopg/psycopg/connection.py index 163e9b865..ef49d0e88 100644 --- a/psycopg/psycopg/connection.py +++ b/psycopg/psycopg/connection.py @@ -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) -- 2.47.2