1010from urllib3 .util import make_headers
1111from urllib3 .exceptions import MaxRetryError
1212
13+ # Compatibility import for different urllib3 versions
14+ try :
15+ # If urllib3~=2.0 is installed
16+ from urllib3 import BaseHTTPResponse
17+ except ImportError :
18+ # If urllib3~=1.0 is installed
19+ from urllib3 import HTTPResponse as BaseHTTPResponse
20+
1321from databricks .sql .auth .retry import DatabricksRetryPolicy , CommandType
1422from databricks .sql .exc import RequestError
1523from databricks .sql .common .http import HttpMethod
@@ -222,7 +230,7 @@ def request_context(
222230 url : str ,
223231 headers : Optional [Dict [str , str ]] = None ,
224232 ** kwargs ,
225- ) -> Generator [urllib3 . BaseHTTPResponse , None , None ]:
233+ ) -> Generator [BaseHTTPResponse , None , None ]:
226234 """
227235 Context manager for making HTTP requests with proper resource cleanup.
228236
@@ -233,7 +241,7 @@ def request_context(
233241 **kwargs: Additional arguments passed to urllib3 request
234242
235243 Yields:
236- urllib3. BaseHTTPResponse: The HTTP response object
244+ BaseHTTPResponse: The HTTP response object
237245 """
238246 logger .debug (
239247 "Making %s request to %s" , method , urllib .parse .urlparse (url ).netloc
@@ -270,7 +278,7 @@ def request(
270278 url : str ,
271279 headers : Optional [Dict [str , str ]] = None ,
272280 ** kwargs ,
273- ) -> urllib3 . BaseHTTPResponse :
281+ ) -> BaseHTTPResponse :
274282 """
275283 Make an HTTP request.
276284
@@ -281,7 +289,7 @@ def request(
281289 **kwargs: Additional arguments passed to urllib3 request
282290
283291 Returns:
284- urllib3. BaseHTTPResponse: The HTTP response object with data and metadata pre-loaded
292+ BaseHTTPResponse: The HTTP response object with data and metadata pre-loaded
285293 """
286294 with self .request_context (method , url , headers = headers , ** kwargs ) as response :
287295 # Read the response data to ensure it's available after context exit
0 commit comments