]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
refactor: drop overloading of the Connection.connect() function
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 3 Jan 2024 01:14:46 +0000 (02:14 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 3 Jan 2024 02:52:00 +0000 (03:52 +0100)
The default for the Row TypeVar makes it redundant.

psycopg/psycopg/connection.py
psycopg/psycopg/connection_async.py

index d0e6391a3f6b885382b92d8e1d8450d20d966673..fe5a2a02a9bb10a45258e4a94d5c3c930282f2d9 100644 (file)
@@ -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 = "",
index ec487e483dc0bff13123a14ca5cd1e1cb464b896..b08375442290857dd3233faf96fd12d003adb252 100644 (file)
@@ -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 = "",