@@ -56,7 +56,7 @@ def __init__(
5656
5757 # Build base URL
5858 self .base_url = f"https://{ server_hostname } :{ self .port } "
59-
59+
6060 # Parse URL for proxy handling
6161 parsed_url = urllib .parse .urlparse (self .base_url )
6262 self .scheme = parsed_url .scheme
@@ -84,7 +84,7 @@ def __init__(
8484
8585 # Setup retry policy
8686 self .enable_v3_retries = kwargs .get ("_enable_v3_retries" , True )
87-
87+
8888 if self .enable_v3_retries :
8989 self .retry_policy = DatabricksRetryPolicy (
9090 delay_min = self ._retry_delay_min ,
@@ -138,13 +138,17 @@ def _open(self):
138138 pool_class = HTTPConnectionPool
139139 else : # https
140140 pool_class = HTTPSConnectionPool
141- pool_kwargs .update ({
142- "cert_reqs" : ssl .CERT_REQUIRED if self .ssl_options .tls_verify else ssl .CERT_NONE ,
143- "ca_certs" : self .ssl_options .tls_trusted_ca_file ,
144- "cert_file" : self .ssl_options .tls_client_cert_file ,
145- "key_file" : self .ssl_options .tls_client_cert_key_file ,
146- "key_password" : self .ssl_options .tls_client_cert_key_password ,
147- })
141+ pool_kwargs .update (
142+ {
143+ "cert_reqs" : ssl .CERT_REQUIRED
144+ if self .ssl_options .tls_verify
145+ else ssl .CERT_NONE ,
146+ "ca_certs" : self .ssl_options .tls_trusted_ca_file ,
147+ "cert_file" : self .ssl_options .tls_client_cert_file ,
148+ "key_file" : self .ssl_options .tls_client_cert_key_file ,
149+ "key_password" : self .ssl_options .tls_client_cert_key_password ,
150+ }
151+ )
148152
149153 if self .proxy_uri :
150154 proxy_manager = ProxyManager (
@@ -253,7 +257,7 @@ def _make_request(
253257
254258 # Handle error responses
255259 error_message = f"SEA HTTP request failed with status { response .status } "
256-
260+
257261 try :
258262 if response .data :
259263 error_details = json .loads (response .data .decode ("utf-8" ))
@@ -262,21 +266,23 @@ def _make_request(
262266 logger .error (f"Request failed: { error_details } " )
263267 except (json .JSONDecodeError , UnicodeDecodeError ):
264268 # Log raw response if we can't parse JSON
265- content = response .data .decode ("utf-8" , errors = "replace" ) if response .data else ""
269+ content = (
270+ response .data .decode ("utf-8" , errors = "replace" ) if response .data else ""
271+ )
266272 logger .error (f"Request failed with non-JSON response: { content } " )
267273
268274 raise RequestError (error_message , None )
269275
270276 def _get_command_type_from_path (self , path : str , method : str ) -> CommandType :
271277 """
272278 Determine the command type based on the API path and method.
273-
279+
274280 This helps the retry policy make appropriate decisions for different
275281 types of SEA operations.
276282 """
277283 path = path .lower ()
278284 method = method .upper ()
279-
285+
280286 if "/statements" in path :
281287 if method == "POST" and path .endswith ("/statements" ):
282288 return CommandType .EXECUTE_STATEMENT
@@ -289,5 +295,5 @@ def _get_command_type_from_path(self, path: str, method: str) -> CommandType:
289295 elif "/sessions" in path :
290296 if method == "DELETE" :
291297 return CommandType .CLOSE_SESSION
292-
298+
293299 return CommandType .OTHER
0 commit comments