]> 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 03:08:01 +0000 (04:08 +0100)
The default for the Row TypeVar makes it redundant.

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

index 55dacb80b83b33417361311961456e8e5f6bfec2..dc02ce3815c359a6759710a174e7a145db596a20 100644 (file)
@@ -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 = "",
index 8f3b5eb3163d805b47f67df8af7c72e6f3cfd612..46269fda4f6fc43bc2b0684a3bbf6937c01fd87b 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 = "",