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: pool-3.2.1~7^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7025f98921e06f9004338cfb36352a06c9d5718f;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 d0e6391a3..fe5a2a02a 100644 --- a/psycopg/psycopg/connection.py +++ b/psycopg/psycopg/connection.py @@ -72,36 +72,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 ec487e483..b08375442 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 = "",