Skip to content

Commit 4cca485

Browse files
Correct typing for connect(), connect_async(), create_pool() and
create_pool_async() (#438) (from PR #444).
1 parent 48020d3 commit 4cca485

File tree

5 files changed

+28
-8
lines changed

5 files changed

+28
-8
lines changed

doc/src/release_notes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ Common Changes
142142
#) All Oracle errors that result in the connection no longer being usable will
143143
be raised as ``DPY-4011: the database or network closed the connection``
144144
with the underlying reason being included in the error message.
145+
#) Fix typing issue with :meth:`oracledb.connect()`,
146+
:meth:`oracledb.connect_async()`, :meth:`oracledb.create_pool()` and
147+
:meth:`oracledb.create_pool_async()`
148+
(`issue 438 <https://github.com/oracle/python-oracledb/issues/438>`__).
145149
#) Error ``DPY-2053: python-oracledb thin mode cannot be used because thick
146150
mode has already been enabled`` is now raised when attempting to use
147151
asyncio in thick mode

src/oracledb/connection.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,9 @@ def unsubscribe(self, subscr: Subscription) -> None:
12061206
subscr._impl.unsubscribe(self._impl)
12071207

12081208

1209-
def _connection_factory(f):
1209+
def _connection_factory(
1210+
f: Callable[..., Connection]
1211+
) -> Callable[..., Connection]:
12101212
"""
12111213
Decorator which checks the validity of the supplied keyword parameters by
12121214
calling the original function (which does nothing), then creates and
@@ -2025,7 +2027,9 @@ async def tpc_rollback(self, xid: Optional[Xid] = None) -> None:
20252027
await self._impl.tpc_rollback(xid)
20262028

20272029

2028-
def _async_connection_factory(f):
2030+
def _async_connection_factory(
2031+
f: Callable[..., AsyncConnection]
2032+
) -> Callable[..., AsyncConnection]:
20292033
"""
20302034
Decorator which checks the validity of the supplied keyword parameters by
20312035
calling the original function (which does nothing), then creates and

src/oracledb/pool.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,9 @@ def reconfigure(
569569
self.ping_interval = ping_interval
570570

571571

572-
def _pool_factory(f):
572+
def _pool_factory(
573+
f: Callable[..., ConnectionPool]
574+
) -> Callable[..., ConnectionPool]:
573575
"""
574576
Decorator which checks the validity of the supplied keyword parameters by
575577
calling the original function (which does nothing), then creates and
@@ -1097,7 +1099,9 @@ async def release(
10971099
await connection.close()
10981100

10991101

1100-
def _async_pool_factory(f):
1102+
def _async_pool_factory(
1103+
f: Callable[..., AsyncConnectionPool]
1104+
) -> Callable[..., AsyncConnectionPool]:
11011105
"""
11021106
Decorator which checks the validity of the supplied keyword parameters by
11031107
calling the original function (which does nothing), then creates and

utils/templates/connection.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,9 @@ def unsubscribe(self, subscr: Subscription) -> None:
12041204
subscr._impl.unsubscribe(self._impl)
12051205

12061206

1207-
def _connection_factory(f):
1207+
def _connection_factory(
1208+
f: Callable[..., Connection]
1209+
) -> Callable[..., Connection]:
12081210
"""
12091211
Decorator which checks the validity of the supplied keyword parameters by
12101212
calling the original function (which does nothing), then creates and
@@ -1775,7 +1777,9 @@ async def tpc_rollback(self, xid: Optional[Xid] = None) -> None:
17751777
await self._impl.tpc_rollback(xid)
17761778

17771779

1778-
def _async_connection_factory(f):
1780+
def _async_connection_factory(
1781+
f: Callable[..., AsyncConnection]
1782+
) -> Callable[..., AsyncConnection]:
17791783
"""
17801784
Decorator which checks the validity of the supplied keyword parameters by
17811785
calling the original function (which does nothing), then creates and

utils/templates/pool.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,9 @@ def reconfigure(
567567
self.ping_interval = ping_interval
568568

569569

570-
def _pool_factory(f):
570+
def _pool_factory(
571+
f: Callable[..., ConnectionPool]
572+
) -> Callable[..., ConnectionPool]:
571573
"""
572574
Decorator which checks the validity of the supplied keyword parameters by
573575
calling the original function (which does nothing), then creates and
@@ -778,7 +780,9 @@ async def release(
778780
await connection.close()
779781

780782

781-
def _async_pool_factory(f):
783+
def _async_pool_factory(
784+
f: Callable[..., AsyncConnectionPool]
785+
) -> Callable[..., AsyncConnectionPool]:
782786
"""
783787
Decorator which checks the validity of the supplied keyword parameters by
784788
calling the original function (which does nothing), then creates and

0 commit comments

Comments
 (0)