Skip to content

Commit 8b00f82

Browse files
committed
update code
1 parent b140dda commit 8b00f82

3 files changed

Lines changed: 9 additions & 17 deletions

File tree

‎boxsdk/client/client.py‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,8 +2043,6 @@ def get_authentication(self, *, token_storage=None):
20432043
Authentication object compatible with the generated SDK (box_sdk_gen).
20442044
:raises ValueError:
20452045
If the authentication type is not supported or required credentials are missing.
2046-
:raises ValueError:
2047-
If the authentication type is not supported or required credentials are missing.
20482046
"""
20492047
oauth = self._oauth
20502048

@@ -2207,7 +2205,6 @@ def get_network_session(
22072205
network_client=None,
22082206
retry_strategy=None,
22092207
data_sanitizer=None,
2210-
interceptors=None,
22112208
additional_headers=None,
22122209
):
22132210
"""
@@ -2222,8 +2219,6 @@ def get_network_session(
22222219
If not provided, one will be created from legacy retry settings.
22232220
:param data_sanitizer:
22242221
Optional DataSanitizer instance for the generated SDK.
2225-
:param interceptors:
2226-
Optional list of request/response interceptors.
22272222
:param additional_headers:
22282223
Optional dictionary of additional HTTP headers to merge with legacy headers.
22292224
:return:
@@ -2275,9 +2270,14 @@ def get_network_session(
22752270
if hasattr(proxy_config, 'AUTH') and proxy_config.AUTH:
22762271
auth = proxy_config.AUTH
22772272
if isinstance(auth, dict) and 'user' in auth and 'password' in auth:
2273+
scheme = (
2274+
proxy_url.split('://', 1)[0] if '://' in proxy_url else 'http'
2275+
)
22782276
# Extract host from URL
22792277
host = proxy_url.split('//')[1] if '//' in proxy_url else proxy_url
2280-
proxy_url = f"http://{auth['user']}:{auth['password']}@{host}"
2278+
proxy_url = (
2279+
f"{scheme}://{auth['user']}:{auth['password']}@{host}"
2280+
)
22812281

22822282
# Merge custom headers
22832283
headers = {}
@@ -2314,7 +2314,6 @@ def get_sdk_gen_client(self, *, auth_options=None, network_options=None):
23142314
- network_client: Custom NetworkClient instance
23152315
- retry_strategy: Custom RetryStrategy instance
23162316
- data_sanitizer: Custom DataSanitizer instance
2317-
- interceptors: List of request/response interceptors
23182317
- additional_headers: Dictionary of additional HTTP headers
23192318
:return:
23202319
BoxClient instance from box_sdk_gen, fully configured with shared settings.
@@ -2333,7 +2332,6 @@ def get_sdk_gen_client(self, *, auth_options=None, network_options=None):
23332332
'network_client': network_options.get('network_client'),
23342333
'retry_strategy': network_options.get('retry_strategy'),
23352334
'data_sanitizer': network_options.get('data_sanitizer'),
2336-
'interceptors': network_options.get('interceptors'),
23372335
'additional_headers': network_options.get('additional_headers'),
23382336
}
23392337

‎docs/config-sharing-implementation.md‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ Extracts network configuration from the legacy client and converts it to a gener
5858
- `network_client` (optional): Custom `NetworkClient` instance
5959
- `retry_strategy` (optional): Custom `RetryStrategy` instance
6060
- `data_sanitizer` (optional): Custom `DataSanitizer` instance
61-
- `interceptors` (optional): List of request/response interceptors
6261
- `additional_headers` (optional): Dictionary of additional HTTP headers
6362

6463
**Returns:**
@@ -88,7 +87,6 @@ Creates a fully configured generated SDK client from the legacy client. This is
8887
- `network_client`: Custom `NetworkClient` instance
8988
- `retry_strategy`: Custom `RetryStrategy` instance
9089
- `data_sanitizer`: Custom `DataSanitizer` instance
91-
- `interceptors`: List of request/response interceptors
9290
- `additional_headers`: Dictionary of additional HTTP headers
9391

9492
**Returns:**
@@ -250,10 +248,9 @@ Network settings are extracted from:
250248

251249
## Error Handling
252250

253-
The implementation includes comprehensive error handling:
251+
The implementation raises:
254252

255-
- `ValueError`: Raised for unsupported auth types or missing credentials
256-
- `TypeError`: Raised for invalid parameter types
253+
- `ValueError`: for unsupported auth types or missing credentials
257254

258255
Note: Since `boxsdk` and `box_sdk_gen` are always installed together, import errors for `box_sdk_gen` should not occur in practice.
259256

‎test/boxsdk/unit/client/test_config_sharing.py‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
Tests get_authentication(), get_network_session(), and get_sdk_gen_client() methods.
55
"""
66

7-
from unittest.mock import Mock, MagicMock, patch
8-
import pytest
9-
10-
from unittest.mock import Mock, MagicMock, patch
7+
from unittest.mock import Mock
118
import pytest
129

1310
from boxsdk.client import Client

0 commit comments

Comments
 (0)