From 7e836db2f315787421b094401f768d7f8957d64d Mon Sep 17 00:00:00 2001 From: Joachim Jablon Date: Tue, 23 Nov 2021 09:40:45 +0100 Subject: [PATCH] Move abstract methods to AbstractConnectionPool (#6340) --- stubs/psycopg2/@tests/stubtest_allowlist.txt | 3 +++ stubs/psycopg2/psycopg2/pool.pyi | 15 ++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/stubs/psycopg2/@tests/stubtest_allowlist.txt b/stubs/psycopg2/@tests/stubtest_allowlist.txt index ea36bb094..0a93eaedc 100644 --- a/stubs/psycopg2/@tests/stubtest_allowlist.txt +++ b/stubs/psycopg2/@tests/stubtest_allowlist.txt @@ -1,2 +1,5 @@ psycopg2.connection psycopg2.cursor +psycopg2.pool.AbstractConnectionPool.closeall +psycopg2.pool.AbstractConnectionPool.getconn +psycopg2.pool.AbstractConnectionPool.putconn diff --git a/stubs/psycopg2/psycopg2/pool.pyi b/stubs/psycopg2/psycopg2/pool.pyi index b3aee45a6..6bcf1b6d9 100644 --- a/stubs/psycopg2/psycopg2/pool.pyi +++ b/stubs/psycopg2/psycopg2/pool.pyi @@ -9,14 +9,15 @@ class AbstractConnectionPool: maxconn: Any closed: bool def __init__(self, minconn, maxconn, *args, **kwargs) -> None: ... + # getconn, putconn and closeall are officially documented as methods of the + # abstract base class, but in reality, they only exist on the children classes + def getconn(self, key: Any | None = ...): ... + def putconn(self, conn: Any, key: Any | None = ..., close: bool = ...) -> None: ... + def closeall(self) -> None: ... -class SimpleConnectionPool(AbstractConnectionPool): - getconn: Any - putconn: Any - closeall: Any +class SimpleConnectionPool(AbstractConnectionPool): ... class ThreadedConnectionPool(AbstractConnectionPool): - def __init__(self, minconn, maxconn, *args, **kwargs) -> None: ... - def getconn(self, key: Any | None = ...): ... + # This subclass has a default value for conn which doesn't exist + # in the SimpleConnectionPool class, nor in the documentation def putconn(self, conn: Any | None = ..., key: Any | None = ..., close: bool = ...) -> None: ... - def closeall(self) -> None: ...