@@ -222,9 +222,7 @@ def __init__(
222222 password = passwd
223223
224224 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" )
228226
229227 self ._local_infile = bool (local_infile )
230228 if self ._local_infile :
@@ -273,9 +271,7 @@ def _config(key, arg):
273271 ssl = {
274272 "ca" : ssl_ca ,
275273 "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 ,
279275 }
280276 if ssl_cert is not None :
281277 ssl ["cert" ] = ssl_cert
@@ -531,9 +527,7 @@ def escape_string(self, s):
531527
532528 def _quote_bytes (self , s ):
533529 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"'&qu
B94A
ot; , b"''" ).decode ("ascii" , "surrogateescape" ))
537531 return converters .escape_bytes (s )
538532
539533 def cursor (self , cursor = None ):
@@ -886,9 +880,7 @@ def _request_authentication(self):
886880 if isinstance (self .user , str ):
887881 self .user = self .user .encode (self .encoding )
888882
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"" )
892884
893885 if self .ssl and self .server_capabilities & CLIENT .SSL :
894886 self .write_packet (data_init )
@@ -961,10 +953,7 @@ def _request_authentication(self):
961953 # https://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::AuthSwitchRequest
962954 auth_packet .read_uint8 () # 0xfe packet identifier
963955 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 :
968957 auth_packet = self ._process_auth (plugin_name , auth_packet )
969958 else :
970959 raise err .OperationalError ("received unknown auth switch request" )
@@ -1006,10 +995,7 @@ def _process_auth(self, plugin_name, auth_packet):
1006995 elif plugin_name == b"client_ed25519" :
1007996 data = _auth .ed25519_password (self .password , auth_packet .read_all ())
1008997 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 "
1013999 elif plugin_name == b"mysql_clear_password" :
10141000 # https://dev.mysql.com/doc/internals/en/clear-text-authentication.html
10151001 data = self .password + b"\0 "
@@ -1032,8 +1018,7 @@ def _process_auth(self, plugin_name, auth_packet):
10321018 raise err .OperationalError (
10331019 CR .CR_AUTH_PLUGIN_CANNOT_LOAD ,
10341020 "Authentication plugin '%s'"
1035- " not loaded: - %r missing prompt method"
1036- % (plugin_name , handler ),
1021+ " not loaded: - %r missing prompt method" % (plugin_name , handler ),
10371022 )
10381023 except TypeError :
10391024 raise err .OperationalError (
@@ -1256,9 +1241,7 @@ def _read_load_local_packet(self, first_packet):
12561241 raise
12571242
12581243 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
12621245 raise err .OperationalError (
12631246 CR .CR_COMMANDS_OUT_OF_SYNC ,
12641247 "Commands Out of Sync" ,
@@ -1413,9 +1396,7 @@ def send_data(self):
14131396
14141397 try :
14151398 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
14191400 while True :
14201401 chunk = open_file .read (packet_size )
14211402 if not chunk :
0 commit comments