Skip to content

Commit 239fdab

Browse files
committed
merge branch
1 parent 761e109 commit 239fdab

4 files changed

Lines changed: 17 additions & 8 deletions

File tree

lib/sqlalchemy/dialects/mysql/aiomysql.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
from types import ModuleType
3535
from typing import Any
36+
from typing import cast
3637
from typing import Optional
3738
from typing import TYPE_CHECKING
3839

@@ -95,10 +96,10 @@ def autocommit(self, value: Any) -> None:
9596

9697
def terminate(self) -> None:
9798
# it's not awaitable.
98-
self._connection.close()
99+
cast(AiomysqlConnection, self._connection).close()
99100

100101
def close(self) -> None:
101-
await_(self._connection.ensure_closed())
102+
await_(cast(AiomysqlConnection, self._connection).ensure_closed())
102103

103104

104105
class AsyncAdapt_aiomysql_dbapi:

lib/sqlalchemy/dialects/mysql/pymysql.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252

5353
from types import ModuleType
5454
from typing import Any
55+
from typing import cast
5556
from typing import Literal
5657
from typing import Optional
5758
from typing import TYPE_CHECKING
@@ -116,9 +117,9 @@ def _send_false_to_ping(self) -> bool:
116117

117118
def do_ping(self, dbapi_connection: pymysql.Connection) -> Literal[True]: # type: ignore # noqa: E501
118119
if self._send_false_to_ping:
119-
dbapi_connection.ping(False)
120+
cast("pymysql.Connection[Any]", dbapi_connection).ping(False)
120121
else:
121-
dbapi_connection.ping()
122+
cast("pymysql.Connection[Any]", dbapi_connection).ping()
122123

123124
return True
124125

@@ -131,6 +132,7 @@ def create_connect_args(
131132
url, _translate_args=_translate_args
132133
)
133134

135+
134136
def is_disconnect(
135137
self, e: Exception, connection: Any, cursor: Any
136138
) -> bool:

lib/sqlalchemy/dialects/mysql/pyodbc.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import datetime
4949
import re
5050
from typing import Any
51+
from typing import cast
5152
from typing import Callable
5253
from typing import Optional
5354
from typing import TYPE_CHECKING
@@ -148,9 +149,13 @@ def on_connect(conn: pyodbc.Connection) -> None:
148149
# https://github.com/mkleehammer/pyodbc/wiki/Unicode
149150
pyodbc_SQL_CHAR = 1 # pyodbc.SQL_CHAR
150151
pyodbc_SQL_WCHAR = -8 # pyodbc.SQL_WCHAR
151-
conn.setdecoding(pyodbc_SQL_CHAR, encoding="utf-8")
152-
conn.setdecoding(pyodbc_SQL_WCHAR, encoding="utf-8")
153-
conn.setencoding(encoding="utf-8")
152+
cast("pyodbc.Connection", conn).setdecoding(
153+
pyodbc_SQL_CHAR, encoding="utf-8"
154+
)
155+
cast("pyodbc.Connection", conn).setdecoding(
156+
pyodbc_SQL_WCHAR, encoding="utf-8"
157+
)
158+
cast("pyodbc.Connection", conn).setencoding(encoding="utf-8")
154159

155160
return on_connect
156161

lib/sqlalchemy/engine/interfaces.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
from .base import Engine
5252
from .cursor import CursorResult
5353
from .url import URL
54+
from ..connectors.asyncio import AsyncIODBAPIConnection
5455
from ..event import _ListenerFnType
5556
from ..event import dispatcher
5657
from ..exc import StatementError
@@ -3357,7 +3358,7 @@ class AdaptedConnection:
33573358

33583359
__slots__ = ("_connection",)
33593360

3360-
_connection: Any
3361+
_connection: AsyncIODBAPIConnection
33613362

33623363
@property
33633364
def driver_connection(self) -> Any:

0 commit comments

Comments
 (0)