@@ -27,20 +27,23 @@ def __init__(
2727 session_id_hex
2828 )
2929 telemetry_client .export_failure_log (error_name , self .message )
30- elif isinstance (self , (ConnectionError , AuthenticationError )) and 'host_url' in self .context :
30+ elif (
31+ isinstance (self , (ConnectionError , AuthenticationError ))
32+ and "host_url" in self .context
33+ ):
3134 # Connection error case: no session but we should still send telemetry
3235 self ._send_connection_error_telemetry (error_name )
3336
3437 def _send_connection_error_telemetry (self , error_name ):
3538 """Send connection error telemetry to unauthenticated endpoint"""
36-
39+
3740 TelemetryClientFactory .send_connection_error_telemetry (
3841 error_name = error_name ,
3942 error_message = self .message or str (self ),
40- host_url = self .context [' host_url' ],
41- http_path = self .context .get (' http_path' , '' ),
42- port = self .context .get (' port' , 443 ),
43- user_agent = self .context .get (' user_agent' ),
43+ host_url = self .context [" host_url" ],
44+ http_path = self .context .get (" http_path" , "" ),
45+ port = self .context .get (" port" , 443 ),
46+ user_agent = self .context .get (" user_agent" ),
4447 )
4548
4649 def __str__ (self ):
@@ -146,38 +149,42 @@ class CursorAlreadyClosedError(RequestError):
146149
147150class ConnectionError (OperationalError ):
148151 """Thrown when connection to Databricks fails during initial setup"""
149-
152+
150153 def __init__ (
151- self ,
152- message = None ,
153- host_url = None ,
154- http_path = None ,
154+ self ,
155+ message = None ,
156+ host_url = None ,
157+ http_path = None ,
155158 port = 443 ,
156159 user_agent = None ,
157160 original_exception = None ,
158161 ** kwargs
159162 ):
160163 # Set up context for connection error telemetry
161- context = kwargs .get (' context' , {})
164+ context = kwargs .get (" context" , {})
162165 if host_url :
163- context .update ({
164- 'host_url' : host_url ,
165- 'http_path' : http_path or '' ,
166- 'port' : port ,
167- 'user_agent' : user_agent ,
168- 'original_exception' : str (original_exception ) if original_exception else None ,
169- })
170-
166+ context .update (
167+ {
168+ "host_url" : host_url ,
169+ "http_path" : http_path or "" ,
170+ "port" : port ,
171+ "user_agent" : user_agent ,
172+ "original_exception" : str (original_exception )
173+ if original_exception
174+ else None ,
175+ }
176+ )
177+
171178 super ().__init__ (message = message , context = context , ** kwargs )
172179
173180
174181class AuthenticationError (ConnectionError ):
175182 """Thrown when authentication to Databricks fails"""
176-
183+
177184 def __init__ (self , message = None , auth_type = None , ** kwargs ):
178- context = kwargs .get (' context' , {})
185+ context = kwargs .get (" context" , {})
179186 if auth_type :
180- context [' auth_type' ] = auth_type
181- kwargs [' context' ] = context
182-
187+ context [" auth_type" ] = auth_type
188+ kwargs [" context" ] = context
189+
183190 super ().__init__ (message = message , ** kwargs )
0 commit comments