Skip to content

Commit a624e46

Browse files
committed
apply additional comments
1 parent eb86cbb commit a624e46

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

_test_unstructured_client/test__decorators.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,7 @@ def test_clean_server_url_fixes_malformed_localhost_url(server_url: str):
5151

5252

5353
def test_clean_server_url_returns_empty_string_given_empty_string():
54-
client = UnstructuredClient(
55-
server_url="",
56-
api_key_auth=FAKE_KEY,
57-
)
54+
client = UnstructuredClient( server_url="", api_key_auth=FAKE_KEY)
5855
assert client.general.sdk_configuration.server_url == ""
5956

6057

src/unstructured_client/utils/_decorators.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@
1818
def clean_server_url(func: Callable[_P, None]) -> Callable[_P, None]:
1919
"""A decorator for fixing common types of malformed 'server_url' arguments.
2020
21-
This decorator addresses the common problem of users omitting or using the wrong url scheme and/or
22-
adding the '/general/v0/general' path to the 'server_url'.
23-
The decorator should be manually applied to the __init__ method of UnstructuredClient after merging
24-
a PR from Speakeasy.
21+
This decorator addresses the common problem of users omitting or using the wrong url scheme
22+
and/or adding the '/general/v0/general' path to the 'server_url'. The decorator should be
23+
manually applied to the __init__ method of UnstructuredClient after merging a PR from Speakeasy.
2524
"""
2625

2726
@functools.wraps(func)
@@ -52,7 +51,11 @@ def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> None:
5251
if url_is_in_kwargs:
5352
kwargs["server_url"] = urlunparse(cleaned_url)
5453
else:
55-
args = args[:SERVER_URL_ARG_IDX] + (urlunparse(cleaned_url),) + args[SERVER_URL_ARG_IDX + 1 :] # type: ignore
54+
args = (
55+
args[:SERVER_URL_ARG_IDX]
56+
+ (urlunparse(cleaned_url),)
57+
+ args[SERVER_URL_ARG_IDX + 1 :]
58+
) # type: ignore
5659

5760
return func(*args, **kwargs)
5861

@@ -62,11 +65,14 @@ def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> None:
6265
def suggest_defining_url_if_401(
6366
func: Callable[_P, operations.PartitionResponse]
6467
) -> Callable[_P, operations.PartitionResponse]:
65-
"""A decorator to suggest defining the 'server_url' parameter if a 401 Unauthorized error is encountered.
66-
67-
This decorator addresses the common problem of users not passing in the 'server_url' when using their paid api key.
68-
The decorator should be manually applied to General.partition after merging a PR from Speakeasy.
68+
"""A decorator to suggest defining the 'server_url' parameter if a 401 Unauthorized error is
69+
encountered.
70+
71+
This decorator addresses the common problem of users not passing in the 'server_url' when
72+
using their paid api key. The decorator should be manually applied to General.partition after
73+
merging a PR from Speakeasy.
6974
"""
75+
7076
@functools.wraps(func)
7177
def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> operations.PartitionResponse:
7278
try:

0 commit comments

Comments
 (0)