Skip to content

Commit 9c4b1df

Browse files
committed
Fix isort, black, pylint and mypy issues
1 parent 31d48dd commit 9c4b1df

File tree

13 files changed

+56
-34
lines changed

13 files changed

+56
-34
lines changed

mysql-connector-python/lib/mysql/connector/aio/abstracts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,9 @@ def __init__(
260260
self._in_transaction: bool = False
261261
self._oci_config_file: Optional[str] = None
262262
self._oci_config_profile: Optional[str] = None
263-
self._webauthn_callback: Optional[
264-
Union[str, Callable[[str], None]]
265-
] = webauthn_callback
263+
self._webauthn_callback: Optional[Union[str, Callable[[str], None]]] = (
264+
webauthn_callback
265+
)
266266

267267
self.converter: Optional[MySQLConverter] = None
268268

mysql-connector-python/lib/mysql/connector/aio/plugins/authentication_kerberos_client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,11 @@ def get_store() -> dict:
203203
"""
204204
krb5ccname = os.environ.get(
205205
"KRB5CCNAME",
206-
f"/tmp/krb5cc_{os.getuid()}"
207-
if os.name == "posix"
208-
else Path("%TEMP%").joinpath("krb5cc"),
206+
(
207+
f"/tmp/krb5cc_{os.getuid()}"
208+
if os.name == "posix"
209+
else Path("%TEMP%").joinpath("krb5cc")
210+
),
209211
)
210212
if not krb5ccname:
211213
raise InterfaceError(

mysql-connector-python/lib/mysql/connector/aio/protocol.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,10 @@ async def read_binary_result( # type: ignore[override]
251251
columns: List[DescriptionType],
252252
count: int = 1,
253253
charset: str = "utf-8",
254-
) -> Tuple[List[Tuple[BinaryProtocolType, ...]], Optional[EofPacketType],]:
254+
) -> Tuple[
255+
List[Tuple[BinaryProtocolType, ...]],
256+
Optional[EofPacketType],
257+
]:
255258
"""Read MySQL binary protocol result.
256259
257260
Reads all or given number of binary resultset rows from the socket.
@@ -280,7 +283,10 @@ async def read_binary_result( # type: ignore[override]
280283
# pylint: disable=invalid-overridden-method
281284
async def read_text_result( # type: ignore[override]
282285
self, sock: MySQLSocket, version: Tuple[int, ...], count: int = 1
283-
) -> Tuple[List[Tuple[Optional[bytes], ...]], Optional[EofPacketType],]:
286+
) -> Tuple[
287+
List[Tuple[Optional[bytes], ...]],
288+
Optional[EofPacketType],
289+
]:
284290
"""Read MySQL text result.
285291
286292
Reads all or given number of rows from the socket.

mysql-connector-python/lib/mysql/connector/conversion.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -752,10 +752,11 @@ def _vector_to_python(
752752
"""
753753
if value is None or isinstance(value, array.array):
754754
return value
755-
elif isinstance(value, (bytes, bytearray)):
755+
756+
if isinstance(value, (bytes, bytearray)):
756757
return array.array(MYSQL_VECTOR_TYPE_CODE, value)
757-
else:
758-
raise TypeError(f"Got unsupported type {value.__class__.__name__}")
758+
759+
raise TypeError(f"Got unsupported type {value.__class__.__name__}")
759760

760761
_long_blob_to_python = _blob_to_python
761762
_medium_blob_to_python = _blob_to_python

mysql-connector-python/lib/mysql/connector/cursor_cext.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@
102102

103103

104104
class _ParamSubstitutor:
105-
106105
"""
107106
Substitutes parameters into SQL statement.
108107
"""
@@ -128,7 +127,6 @@ def remaining(self) -> int:
128127

129128

130129
class CMySQLCursor(MySQLCursorAbstract):
131-
132130
"""Default cursor for interacting with MySQL using C Extension"""
133131

134132
_raw: bool = False
@@ -746,6 +744,7 @@ def stored_results(self) -> Generator[CMySQLCursor, None, None]:
746744
747745
Returns a iterator.
748746
"""
747+
# pylint: disable=use-yield-from
749748
for result in self._stored_results:
750749
yield result # type: ignore[misc]
751750
self._stored_results = []
@@ -819,7 +818,6 @@ def __str__(self) -> str:
819818

820819

821820
class CMySQLCursorBuffered(CMySQLCursor):
822-
823821
"""Cursor using C Extension buffering results"""
824822

825823
def __init__(self, connection: CMySQLConnection):

mysql-connector-python/lib/mysql/connector/custom_types.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434

3535
class HexLiteral(str):
36-
3736
"""Class holding MySQL hex literals"""
3837

3938
charset: str = ""

mysql-connector-python/lib/mysql/connector/opentelemetry/instrumentation.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,11 @@ def with_cnx_span_attached(method: Callable) -> Callable:
212212

213213
def wrapper(cnx: "MySQLConnectionAbstract", *args: Any, **kwargs: Any) -> Any:
214214
"""Connection span attacher decorator."""
215-
with trace.use_span(
216-
cnx._span, end_on_exit=False
217-
) if cnx._span and cnx._span.is_recording() else nullcontext():
215+
with (
216+
trace.use_span(cnx._span, end_on_exit=False)
217+
if cnx._span and cnx._span.is_recording()
218+
else nullcontext()
219+
):
218220
return method(cnx, *args, **kwargs)
219221

220222
return wrapper
@@ -235,12 +237,16 @@ def wrapper(cnx: TracedMySQLConnection, *args: Any, **kwargs: Any) -> Any:
235237
"connection_type": cnx.get_wrapped_class(),
236238
}
237239

238-
with cnx._tracer.start_as_current_span(
239-
name=method.__name__.upper(),
240-
kind=trace.SpanKind.CLIENT,
241-
links=[trace.Link(cnx._span.get_span_context())],
242-
attributes=query_span_attributes,
243-
) if cnx._span and cnx._span.is_recording() else nullcontext():
240+
with (
241+
cnx._tracer.start_as_current_span(
242+
name=method.__name__.upper(),
243+
kind=trace.SpanKind.CLIENT,
244+
links=[trace.Link(cnx._span.get_span_context())],
245+
attributes=query_span_attributes,
246+
)
247+
if cnx._span and cnx._span.is_recording()
248+
else nullcontext()
249+
):
244250
return method(cnx, *args, **kwargs)
245251

246252
return wrapper

mysql-connector-python/lib/mysql/connector/plugins/authentication_kerberos_client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,11 @@ def get_store() -> dict:
202202
"""
203203
krb5ccname = os.environ.get(
204204
"KRB5CCNAME",
205-
f"/tmp/krb5cc_{os.getuid()}"
206-
if os.name == "posix"
207-
else Path("%TEMP%").joinpath("krb5cc"),
205+
(
206+
f"/tmp/krb5cc_{os.getuid()}"
207+
if os.name == "posix"
208+
else Path("%TEMP%").joinpath("krb5cc")
209+
),
208210
)
209211
if not krb5ccname:
210212
raise InterfaceError(

mysql-connector-python/lib/mysql/connector/protocol.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,10 @@ def parse_statistics(packet: bytes, with_header: bool = True) -> StatsPacketType
618618

619619
def read_text_result(
620620
self, sock: MySQLSocket, version: Tuple[int, ...], count: int = 1
621-
) -> Tuple[List[Tuple[Optional[bytes], ...]], Optional[EofPacketType],]:
621+
) -> Tuple[
622+
List[Tuple[Optional[bytes], ...]],
623+
Optional[EofPacketType],
624+
]:
622625
"""Read MySQL text result
623626
624627
Reads all or given number of rows from the socket.
@@ -821,7 +824,10 @@ def read_binary_result(
821824
columns: List[DescriptionType],
822825
count: int = 1,
823826
charset: str = "utf-8",
824-
) -> Tuple[List[Tuple[BinaryProtocolType, ...]], Optional[EofPacketType],]:
827+
) -> Tuple[
828+
List[Tuple[BinaryProtocolType, ...]],
829+
Optional[EofPacketType],
830+
]:
825831
"""Read MySQL binary protocol result
826832
827833
Reads all or given number of binary resultset rows from the socket.

mysqlx-connector-python/lib/mysqlx/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"""Constants."""
3030

3131
from enum import Enum
32+
3233
from . import tls_ciphers
3334

3435

mysqlx-connector-python/lib/mysqlx/expr.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -973,9 +973,9 @@ def parse_place_holder(self, token: Token) -> MessageType:
973973
msg_expr["position"] = self.placeholder_name_to_position[place_holder_name]
974974
else:
975975
msg_expr["position"] = self.positional_placeholder_count
976-
self.placeholder_name_to_position[
977-
place_holder_name
978-
] = self.positional_placeholder_count
976+
self.placeholder_name_to_position[place_holder_name] = (
977+
self.positional_placeholder_count
978+
)
979979
self.positional_placeholder_count += 1
980980
return msg_expr
981981

mysqlx-connector-python/lib/mysqlx/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
from typing import Any, Callable, List, Optional, Union
3838

39-
from .constants import TLS_CIPHER_SUITES, SUPPORTED_TLS_VERSIONS
39+
from .constants import SUPPORTED_TLS_VERSIONS, TLS_CIPHER_SUITES
4040
from .errors import InterfaceError
4141
from .types import EscapeTypes, StrOrBytes
4242

mysqlx-connector-python/lib/mysqlx/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@
3131
import os
3232
import subprocess
3333
import sys
34+
import warnings
3435

3536
from typing import Dict, Optional, Tuple
36-
import warnings
37+
3738
from .tls_ciphers import DEPRECATED_TLS_CIPHERSUITES, DEPRECATED_TLS_VERSIONS
3839

3940

0 commit comments

Comments
 (0)