|
1 | 1 | from __future__ import annotations |
2 | | -from typing import Dict, List, Optional, Union |
| 2 | +from typing import Any, Dict, List, Optional, Tuple, Union, Sequence |
3 | 3 |
|
4 | 4 | from dateutil import parser |
5 | 5 | import datetime |
|
9 | 9 | from collections.abc import Mapping |
10 | 10 | from decimal import Decimal |
11 | 11 | from enum import Enum |
12 | | -from typing import Any, Dict, List, Optional, Tuple, Union, Sequence |
13 | 12 | import re |
14 | 13 |
|
15 | 14 | import lz4.frame |
@@ -906,30 +905,23 @@ def build_client_context(server_hostname: str, version: str, **kwargs): |
906 | 905 | else: |
907 | 906 | user_agent = f"PyDatabricksSqlConnector/{version}" |
908 | 907 |
|
909 | | - # Build ClientContext kwargs, excluding None values to use defaults |
910 | | - context_kwargs = { |
911 | | - "hostname": server_hostname, |
912 | | - "ssl_options": ssl_options, |
913 | | - "user_agent": user_agent, |
914 | | - } |
915 | | - |
916 | | - # Only add non-None values to let defaults work |
917 | | - for param, kwarg_key in [ |
918 | | - ("socket_timeout", "_socket_timeout"), |
919 | | - ("retry_stop_after_attempts_count", "_retry_stop_after_attempts_count"), |
920 | | - ("retry_delay_min", "_retry_delay_min"), |
921 | | - ("retry_delay_max", "_retry_delay_max"), |
922 | | - ("retry_stop_after_attempts_duration", "_retry_stop_after_attempts_duration"), |
923 | | - ("retry_delay_default", "_retry_delay_default"), |
924 | | - ("retry_dangerous_codes", "_retry_dangerous_codes"), |
925 | | - ("http_proxy", "_http_proxy"), |
926 | | - ("proxy_username", "_proxy_username"), |
927 | | - ("proxy_password", "_proxy_password"), |
928 | | - ("pool_connections", "_pool_connections"), |
929 | | - ("pool_maxsize", "_pool_maxsize"), |
930 | | - ]: |
931 | | - value = kwargs.get(kwarg_key) |
932 | | - if value is not None: |
933 | | - context_kwargs[param] = value |
934 | | - |
935 | | - return ClientContext(**context_kwargs) |
| 908 | + # Explicitly construct ClientContext with proper types |
| 909 | + return ClientContext( |
| 910 | + hostname=server_hostname, |
| 911 | + ssl_options=ssl_options, |
| 912 | + user_agent=user_agent, |
| 913 | + socket_timeout=kwargs.get("_socket_timeout"), |
| 914 | + retry_stop_after_attempts_count=kwargs.get("_retry_stop_after_attempts_count"), |
| 915 | + retry_delay_min=kwargs.get("_retry_delay_min"), |
| 916 | + retry_delay_max=kwargs.get("_retry_delay_max"), |
| 917 | + retry_stop_after_attempts_duration=kwargs.get( |
| 918 | + "_retry_stop_after_attempts_duration" |
| 919 | + ), |
| 920 | + retry_delay_default=kwargs.get("_retry_delay_default"), |
| 921 | + retry_dangerous_codes=kwargs.get("_retry_dangerous_codes"), |
| 922 | + http_proxy=kwargs.get("_http_proxy"), |
| 923 | + proxy_username=kwargs.get("_proxy_username"), |
| 924 | + proxy_password=kwargs.get("_proxy_password"), |
| 925 | + pool_connections=kwargs.get("_pool_connections"), |
| 926 | + pool_maxsize=kwargs.get("_pool_maxsize"), |
| 927 | + ) |
0 commit comments