@@ -222,9 +222,7 @@ def __init__(
222
222
password = passwd
223
223
224
224
if compress or named_pipe :
225
- raise NotImplementedError (
226
- "compress and named_pipe arguments are not supported"
227
- )
225
+ raise NotImplementedError ("compress and named_pipe arguments are not supported" )
228
226
229
227
self ._local_infile = bool (local_infile )
230
228
if self ._local_infile :
@@ -273,9 +271,7 @@ def _config(key, arg):
273
271
ssl = {
274
272
"ca" : ssl_ca ,
275
273
"check_hostname" : bool (ssl_verify_identity ),
276
- "verify_mode" : ssl_verify_cert
277
- if ssl_verify_cert is not None
278
- else False ,
274
+ "verify_mode" : ssl_verify_cert if ssl_verify_cert is not None else False ,
279
275
}
280
276
if ssl_cert is not None :
281
277
ssl ["cert" ] = ssl_cert
@@ -531,9 +527,7 @@ def escape_string(self, s):
531
527
532
528
def _quote_bytes (self , s ):
533
529
if self .server_status & SERVER_STATUS .SERVER_STATUS_NO_BACKSLASH_ESCAPES :
534
- return "'{}'" .format (
535
- s .replace (b"'" , b"''" ).decode ("ascii" , "surrogateescape" )
536
- )
530
+ return "'{}'" .format (s .replace (b"'" , b"''" ).decode ("ascii" , "surrogateescape" ))
537
531
return converters .escape_bytes (s )
538
532
539
533
def cursor (self , cursor = None ):
@@ -886,9 +880,7 @@ def _request_authentication(self):
886
880
if isinstance (self .user , str ):
887
881
self .user = self .user .encode (self .encoding )
888
882
889
- data_init = struct .pack (
890
- "<iIB23s" , self .client_flag , MAX_PACKET_LEN , charset_id , b""
891
- )
883
+ data_init = struct .pack ("<iIB23s" , self .client_flag , MAX_PACKET_LEN , charset_id , b"" )
892
884
893
885
if self .ssl and self .server_capabilities & CLIENT .SSL :
894
886
self .write_packet (data_init )
@@ -961,10 +953,7 @@ def _request_authentication(self):
961
953
# https://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::AuthSwitchRequest
962
954
auth_packet .read_uint8 () # 0xfe packet identifier
963
955
plugin_name = auth_packet .read_string ()
964
- if (
965
- self .server_capabilities & CLIENT .PLUGIN_AUTH
966
- and plugin_name is not None
967
- ):
956
+ if self .server_capabilities & CLIENT .PLUGIN_AUTH and plugin_name is not None :
968
957
auth_packet = self ._process_auth (plugin_name , auth_packet )
969
958
else :
970
959
raise err .OperationalError ("received unknown auth switch request" )
@@ -1006,10 +995,7 @@ def _process_auth(self, plugin_name, auth_packet):
1006
995
elif plugin_name == b"client_ed25519" :
1007
996
data = _auth .ed25519_password (self .password , auth_packet .read_all ())
1008
997
elif plugin_name == b"mysql_old_password" :
1009
- data = (
1010
- _auth .scramble_old_password (self .password , auth_packet .read_all ())
1011
- + b"\0 "
1012
- )
998
+ data = _auth .scramble_old_password (self .password , auth_packet .read_all ()) + b"\0 "
1013
999
elif plugin_name == b"mysql_clear_password" :
1014
1000
# https://dev.mysql.com/doc/internals/en/clear-text-authentication.html
1015
1001
data = self .password + b"\0 "
@@ -1032,8 +1018,7 @@ def _process_auth(self, plugin_name, auth_packet):
1032
1018
raise err .OperationalError (
1033
1019
CR .CR_AUTH_PLUGIN_CANNOT_LOAD ,
1034
1020
"Authentication plugin '%s'"
1035
- " not loaded: - %r missing prompt method"
1036
- % (plugin_name , handler ),
1021
+ " not loaded: - %r missing prompt method" % (plugin_name , handler ),
1037
1022
)
1038
1023
except TypeError :
1039
1024
raise err .OperationalError (
@@ -1256,9 +1241,7 @@ def _read_load_local_packet(self, first_packet):
1256
1241
raise
1257
1242
1258
1243
ok_packet = self .connection ._read_packet ()
1259
- if (
1260
- not ok_packet .is_ok_packet ()
1261
- ): # pragma: no cover - upstream induced protocol error
1244
+ if not ok_packet .is_ok_packet (): # pragma: no cover - upstream induced protocol error
1262
1245
raise err .OperationalError (
1263
1246
CR .CR_COMMANDS_OUT_OF_SYNC ,
1264
1247
"Commands Out of Sync" ,
@@ -1413,9 +1396,7 @@ def send_data(self):
1413
1396
1414
1397
try :
1415
1398
with open (self .filename , "rb" ) as open_file :
1416
- packet_size = min (
1417
- conn .max_allowed_packet , 16 * 1024
1418
- ) # 16KB is efficient enough
1399
+ packet_size = min (conn .max_allowed_packet , 16 * 1024 ) # 16KB is efficient enough
1419
1400
while True :
1420
1401
chunk = open_file .read (packet_size )
1421
1402
if not chunk :
0 commit comments