Skip to content

Commit cd2457c

Browse files
committed
chore: disable flake8 warnings for special imports
1 parent f385c7e commit cd2457c

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

aws_advanced_python_wrapper/mysql_driver_dialect.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,30 @@
2323
from concurrent.futures import Executor, ThreadPoolExecutor, TimeoutError
2424
from inspect import signature
2525

26+
from aws_advanced_python_wrapper.driver_dialect import DriverDialect
27+
from aws_advanced_python_wrapper.driver_dialect_codes import DriverDialectCodes
28+
from aws_advanced_python_wrapper.errors import UnsupportedOperationError
29+
from aws_advanced_python_wrapper.utils.decorators import timeout
30+
from aws_advanced_python_wrapper.utils.messages import Messages
31+
from aws_advanced_python_wrapper.utils.properties import (Properties,
32+
PropertiesUtils,
33+
WrapperProperties)
34+
2635
CMYSQL_ENABLED = False
2736

28-
from mysql.connector import MySQLConnection
29-
from mysql.connector.cursor import MySQLCursor
37+
from mysql.connector import MySQLConnection # noqa: E402
38+
from mysql.connector.cursor import MySQLCursor # noqa: E402
3039

3140
try:
32-
from mysql.connector import CMySQLConnection
33-
from mysql.connector.cursor_cext import CMySQLCursor
41+
from mysql.connector import CMySQLConnection # noqa: E402
42+
from mysql.connector.cursor_cext import CMySQLCursor # noqa: E402
3443

3544
CMYSQL_ENABLED = True
3645

3746
except ImportError:
3847
# Do nothing
3948
pass
4049

41-
from aws_advanced_python_wrapper.driver_dialect import DriverDialect
42-
from aws_advanced_python_wrapper.driver_dialect_codes import DriverDialectCodes
43-
from aws_advanced_python_wrapper.errors import UnsupportedOperationError
44-
from aws_advanced_python_wrapper.utils.decorators import timeout
45-
from aws_advanced_python_wrapper.utils.messages import Messages
46-
from aws_advanced_python_wrapper.utils.properties import (Properties,
47-
PropertiesUtils,
48-
WrapperProperties)
49-
5050

5151
class MySQLDriverDialect(DriverDialect):
5252
_driver_name = "MySQL Connector Python"
@@ -94,7 +94,7 @@ def is_closed(self, conn: Connection) -> bool:
9494
if self.can_execute_query(conn):
9595
socket_timeout = WrapperProperties.SOCKET_TIMEOUT_SEC.get_float(self._props)
9696
timeout_sec = socket_timeout if socket_timeout > 0 else MySQLDriverDialect.IS_CLOSED_TIMEOUT_SEC
97-
is_connected_with_timeout = timeout(MySQLDriverDialect._executor, timeout_sec)(conn.is_connected) # type: ignore
97+
is_connected_with_timeout = timeout(MySQLDriverDialect._executor, timeout_sec)(conn.is_connected) # type: ignore
9898

9999
try:
100100
return not is_connected_with_timeout()
@@ -106,14 +106,14 @@ def is_closed(self, conn: Connection) -> bool:
106106

107107
def get_autocommit(self, conn: Connection) -> bool:
108108
if MySQLDriverDialect._is_mysql_connection(conn):
109-
return conn.autocommit # type: ignore
109+
return conn.autocommit # type: ignore
110110

111111
raise UnsupportedOperationError(
112112
Messages.get_formatted("DriverDialect.UnsupportedOperationError", self._driver_name, "autocommit"))
113113

114114
def set_autocommit(self, conn: Connection, autocommit: bool):
115115
if MySQLDriverDialect._is_mysql_connection(conn):
116-
conn.autocommit = autocommit # type: ignore
116+
conn.autocommit = autocommit # type: ignore
117117
return
118118

119119
raise UnsupportedOperationError(
@@ -132,13 +132,13 @@ def abort_connection(self, conn: Connection):
132132

133133
def can_execute_query(self, conn: Connection) -> bool:
134134
if MySQLDriverDialect._is_mysql_connection(conn):
135-
if conn.unread_result: # type: ignore
136-
return conn.can_consume_results # type: ignore
135+
if conn.unread_result: # type: ignore
136+
return conn.can_consume_results # type: ignore
137137
return True
138138

139139
def is_in_transaction(self, conn: Connection) -> bool:
140140
if MySQLDriverDialect._is_mysql_connection(conn):
141-
return bool(conn.in_transaction) # type: ignore
141+
return bool(conn.in_transaction) # type: ignore
142142

143143
raise UnsupportedOperationError(
144144
Messages.get_formatted("DriverDialect.UnsupportedOperationError", self._driver_name,
@@ -176,7 +176,7 @@ def get_connection_from_obj(self, obj: object) -> Any:
176176

177177
def transfer_session_state(self, from_conn: Connection, to_conn: Connection):
178178
if MySQLDriverDialect._is_mysql_connection(from_conn) and MySQLDriverDialect._is_mysql_connection(to_conn):
179-
to_conn.autocommit = from_conn.autocommit # type: ignore
179+
to_conn.autocommit = from_conn.autocommit # type: ignore
180180

181181
def ping(self, conn: Connection) -> bool:
182182
return not self.is_closed(conn)

0 commit comments

Comments
 (0)