From: Daniele Varrazzo Date: Wed, 3 Jan 2024 01:14:46 +0000 (+0100) Subject: refactor: drop overloading of the Connection.connect() function X-Git-Tag: 3.2.0~106^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ebd1925edf83819d8e719251709c7cba1c06615;p=thirdparty%2Fpsycopg.git refactor: drop overloading of the Connection.connect() function The default for the Row TypeVar makes it redundant. --- diff --git a/psycopg/psycopg/connection.py b/psycopg/psycopg/connection.py index 55dacb80b..dc02ce381 100644 --- a/psycopg/psycopg/connection.py +++ b/psycopg/psycopg/connection.py @@ -73,36 +73,7 @@ class Connection(BaseConnection[Row]): self.cursor_factory = Cursor self.server_cursor_factory = ServerCursor - @overload - @classmethod - def connect( - cls, - conninfo: str = "", - *, - autocommit: bool = False, - prepare_threshold: Optional[int] = 5, - row_factory: RowFactory[Row], - cursor_factory: Optional[Type[Cursor[Row]]] = None, - context: Optional[AdaptContext] = None, - **kwargs: Union[None, int, str], - ) -> Self: - ... - - @overload @classmethod - def connect( - cls, - conninfo: str = "", - *, - autocommit: bool = False, - prepare_threshold: Optional[int] = 5, - cursor_factory: Optional[Type[Cursor[Any]]] = None, - context: Optional[AdaptContext] = None, - **kwargs: Union[None, int, str], - ) -> Self: - ... - - @classmethod # type: ignore[misc] # https://github.com/python/mypy/issues/11004 def connect( cls, conninfo: str = "", diff --git a/psycopg/psycopg/connection_async.py b/psycopg/psycopg/connection_async.py index 8f3b5eb31..46269fda4 100644 --- a/psycopg/psycopg/connection_async.py +++ b/psycopg/psycopg/connection_async.py @@ -78,36 +78,7 @@ class AsyncConnection(BaseConnection[Row]): self.cursor_factory = AsyncCursor self.server_cursor_factory = AsyncServerCursor - @overload - @classmethod - async def connect( - cls, - conninfo: str = "", - *, - autocommit: bool = False, - prepare_threshold: Optional[int] = 5, - row_factory: AsyncRowFactory[Row], - cursor_factory: Optional[Type[AsyncCursor[Row]]] = None, - context: Optional[AdaptContext] = None, - **kwargs: Union[None, int, str], - ) -> Self: - ... - - @overload @classmethod - async def connect( - cls, - conninfo: str = "", - *, - autocommit: bool = False, - prepare_threshold: Optional[int] = 5, - cursor_factory: Optional[Type[AsyncCursor[Any]]] = None, - context: Optional[AdaptContext] = None, - **kwargs: Union[None, int, str], - ) -> Self: - ... - - @classmethod # type: ignore[misc] # https://github.com/python/mypy/issues/11004 async def connect( cls, conninfo: str = "",