File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3333
3434from types import ModuleType
3535from typing import Any
36+ from typing import cast
3637from typing import Optional
3738from 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
104105class AsyncAdapt_aiomysql_dbapi :
Original file line number Diff line number Diff line change 5252
5353from types import ModuleType
5454from typing import Any
55+ from typing import cast
5556from typing import Literal
5657from typing import Optional
5758from 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 :
Original file line number Diff line number Diff line change 4848import datetime
4949import re
5050from typing import Any
51+ from typing import cast
5152from typing import Callable
5253from typing import Optional
5354from 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
Original file line number Diff line number Diff line change 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 :
You can’t perform that action at this time.
0 commit comments