Skip to content

Commit a84faaa

Browse files
authored
Add api changed from sqlalchemy/sqlalchemy#6832 (#177)
1 parent df108f2 commit a84faaa

File tree

6 files changed

+30
-4
lines changed

6 files changed

+30
-4
lines changed

sqlalchemy-stubs/dialects/mysql/aiomysql.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ from typing import Any
22
from typing import Optional
33

44
from .pymysql import MySQLDialect_pymysql as MySQLDialect_pymysql
5+
from ...engine import AdaptedConnection
56
from ... import pool as pool
67
from ... import util as util
78
from ...util.concurrency import await_fallback as await_fallback
@@ -39,7 +40,7 @@ class AsyncAdapt_aiomysql_ss_cursor(AsyncAdapt_aiomysql_cursor):
3940
def fetchmany(self, size: Optional[Any] = ...): ...
4041
def fetchall(self): ...
4142

42-
class AsyncAdapt_aiomysql_connection:
43+
class AsyncAdapt_aiomysql_connection(AdaptedConnection):
4344
await_: Any = ...
4445
dbapi: Any = ...
4546
def __init__(self, dbapi: Any, connection: Any) -> None: ...
@@ -71,5 +72,6 @@ class MySQLDialect_aiomysql(MySQLDialect_pymysql):
7172
def get_pool_class(cls, url: Any): ...
7273
def create_connect_args(self, url: Any): ...
7374
def is_disconnect(self, e: Any, connection: Any, cursor: Any): ...
75+
def get_driver_connection(self, connection: Any) -> Any:
7476

7577
dialect = MySQLDialect_aiomysql

sqlalchemy-stubs/dialects/postgresql/asyncpg.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ from .base import PGExecutionContext as PGExecutionContext
1111
from .base import PGIdentifierPreparer as PGIdentifierPreparer
1212
from .base import REGCLASS as REGCLASS
1313
from .base import UUID as UUID
14+
from ...engine import AdaptedConnection
1415
from ... import exc as exc
1516
from ... import pool as pool
1617
from ... import processors as processors
@@ -117,7 +118,7 @@ class AsyncAdapt_asyncpg_ss_cursor(AsyncAdapt_asyncpg_cursor):
117118
def fetchall(self): ...
118119
def executemany(self, operation: Any, seq_of_parameters: Any) -> None: ...
119120

120-
class AsyncAdapt_asyncpg_connection:
121+
class AsyncAdapt_asyncpg_connection(AdaptedConnection):
121122
await_: Any = ...
122123
dbapi: Any = ...
123124
isolation_level: str = ...
@@ -211,5 +212,6 @@ class PGDialect_asyncpg(PGDialect):
211212
self, cursor: Any, list_of_tuples: Any, context: Any
212213
) -> None: ...
213214
def on_connect(self): ...
215+
def get_driver_connection(self, connection: Any) -> Any:
214216

215217
dialect = PGDialect_asyncpg

sqlalchemy-stubs/engine/__init__.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ from .cursor import BufferedRowResultProxy as BufferedRowResultProxy
1515
from .cursor import CursorResult as CursorResult
1616
from .cursor import FullyBufferedResultProxy as FullyBufferedResultProxy
1717
from .cursor import LegacyCursorResult as LegacyCursorResult
18+
from .interfaces import AdaptedConnection as AdaptedConnection
1819
from .interfaces import Compiled as Compiled
1920
from .interfaces import Connectable as Connectable
2021
from .interfaces import CreateEnginePlugin as CreateEnginePlugin

sqlalchemy-stubs/engine/default.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ class DefaultDialect(interfaces.Dialect):
198198
) -> None: ...
199199
def normalize_name(self, name: Optional[str]) -> Optional[str]: ...
200200
def denormalize_name(self, name: Optional[str]) -> Optional[str]: ...
201+
def get_driver_connection(
202+
self, connection: interfaces._DBAPIConnection
203+
) -> Any: ...
201204

202205
class StrCompileDialect(DefaultDialect):
203206
statement_compiler: Type[compiler.StrSQLCompiler] = ...

sqlalchemy-stubs/engine/interfaces.pyi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ class Dialect:
300300
def load_provisioning(cls) -> None: ...
301301
@classmethod
302302
def engine_created(cls, engine: Engine) -> None: ...
303+
def get_driver_connection(self, connection: _DBAPIConnection) -> Any: ...
303304

304305
class CreateEnginePlugin:
305306
url: URL = ...
@@ -362,3 +363,7 @@ class ExceptionContext:
362363
execution_context: Optional[ExecutionContext] = ...
363364
is_disconnect: bool = ...
364365
invalidate_pool_on_disconnect: bool = ...
366+
367+
class AdaptedConnection:
368+
@property
369+
def driver_connection(self) -> Any: ...

sqlalchemy-stubs/pool/base.pyi

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Any
22
from typing import Optional
33

4+
from ..engine.interfaces import _DBAPIConnection
45
from .. import event as event
56
from .. import exc as exc
67
from .. import log as log
@@ -43,7 +44,13 @@ class _ConnectionRecord:
4344
fresh: bool = ...
4445
fairy_ref: Any = ...
4546
starttime: Any = ...
46-
connection: Any = ...
47+
dbapi_connection: _DBAPIConnection = ...
48+
@property
49+
def driver_connection(self) -> Any: ...
50+
@property
51+
def connection(self) -> _DBAPIConnection: ...
52+
@connection.setter
53+
def connection(self, value: _DBAPIConnection) -> None: ...
4754
@util.memoized_property
4855
def info(self): ...
4956
@util.memoized_property
@@ -60,7 +67,13 @@ class _ConnectionRecord:
6067
def get_connection(self): ...
6168

6269
class _ConnectionFairy:
63-
connection: Any = ...
70+
dbapi_connection: _DBAPIConnection = ...
71+
@property
72+
def driver_connection(self) -> Any: ...
73+
@property
74+
def connection(self) -> _DBAPIConnection: ...
75+
@connection.setter
76+
def connection(self, value: _DBAPIConnection) -> None: ...
6477
def __init__(
6578
self, dbapi_connection: Any, connection_record: Any, echo: Any
6679
) -> None: ...

0 commit comments

Comments
 (0)