Skip to content

Commit b4a7c8f

Browse files
committed
blacken files
1 parent 260412f commit b4a7c8f

File tree

2 files changed

+27
-17
lines changed

2 files changed

+27
-17
lines changed

_test_unstructured_client/test__decorators.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,32 @@
1111
@pytest.mark.parametrize(
1212
("server_url"),
1313
[
14-
("https://unstructured-000mock.api.unstructuredapp.io"), # correct url
14+
("https://unstructured-000mock.api.unstructuredapp.io"), # correct url
1515
("unstructured-000mock.api.unstructuredapp.io"),
1616
("http://unstructured-000mock.api.unstructuredapp.io/general/v0/general"),
1717
("https://unstructured-000mock.api.unstructuredapp.io/general/v0/general"),
1818
("unstructured-000mock.api.unstructuredapp.io/general/v0/general"),
19-
]
19+
],
2020
)
2121
def test_clean_server_url_on_paid_api_url(server_url: str):
2222
client = UnstructuredClient(
2323
server_url=server_url,
2424
api_key_auth=FAKE_KEY,
2525
)
26-
assert client.general.sdk_configuration.server_url == "https://unstructured-000mock.api.unstructuredapp.io"
26+
assert (
27+
client.general.sdk_configuration.server_url
28+
== "https://unstructured-000mock.api.unstructuredapp.io"
29+
)
2730

2831

2932
@pytest.mark.parametrize(
3033
("server_url"),
3134
[
32-
("http://localhost:8000"), # correct url
35+
("http://localhost:8000"), # correct url
3336
("localhost:8000"),
3437
("localhost:8000/general/v0/general"),
3538
("http://localhost:8000/general/v0/general"),
36-
]
39+
],
3740
)
3841
def test_clean_server_url_on_localhost(server_url: str):
3942
client = UnstructuredClient(
@@ -56,15 +59,18 @@ def test_clean_server_url_on_empty_string():
5659
[
5760
("https://unstructured-000mock.api.unstructuredapp.io"),
5861
("unstructured-000mock.api.unstructuredapp.io/general/v0/general"),
59-
]
62+
],
6063
)
6164
def test_clean_server_url_with_positional_arguments(server_url: str):
6265
client = UnstructuredClient(
6366
FAKE_KEY,
6467
"",
6568
server_url,
6669
)
67-
assert client.general.sdk_configuration.server_url == "https://unstructured-000mock.api.unstructuredapp.io"
70+
assert (
71+
client.general.sdk_configuration.server_url
72+
== "https://unstructured-000mock.api.unstructuredapp.io"
73+
)
6874

6975

7076
def test_suggest_defining_url_if_401():
@@ -73,11 +79,11 @@ def test_suggest_defining_url_if_401():
7379
client = UnstructuredClient(
7480
api_key_auth=FAKE_KEY,
7581
)
76-
82+
7783
filename = "_sample_docs/layout-parser-paper-fast.pdf"
78-
84+
7985
with open(filename, "rb") as f:
80-
files=shared.Files(
86+
files = shared.Files(
8187
content=f.read(),
8288
file_name=filename,
8389
)

src/unstructured_client/utils/_decorators.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,29 @@ def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> None:
4545
if url_is_in_kwargs:
4646
kwargs["server_url"] = urlunparse(cleaned_url)
4747
else:
48-
args = args[:SERVER_URL_ARG_IDX] + (urlunparse(cleaned_url),) + args[SERVER_URL_ARG_IDX+1:] # type: ignore
49-
48+
args = args[:SERVER_URL_ARG_IDX] + (urlunparse(cleaned_url),) + args[SERVER_URL_ARG_IDX + 1 :] # type: ignore
49+
5050
return func(*args, **kwargs)
5151

5252
return wrapper
5353

5454

55-
def suggest_defining_url_if_401(func: Callable[_P, operations.PartitionResponse]) -> Callable[_P, operations.PartitionResponse]:
55+
def suggest_defining_url_if_401(
56+
func: Callable[_P, operations.PartitionResponse]
57+
) -> Callable[_P, operations.PartitionResponse]:
5658

5759
@functools.wraps(func)
5860
def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> operations.PartitionResponse:
5961
try:
6062
return func(*args, **kwargs)
6163
except errors.SDKError as e:
6264
if e.status_code == 401:
63-
general_obj: General = args[0] # type: ignore
65+
general_obj: General = args[0] # type: ignore
6466
if not general_obj.sdk_configuration.server_url:
65-
warnings.warn("If intending to use the paid API, please define `server_url` in your request.")
66-
67+
warnings.warn(
68+
"If intending to use the paid API, please define `server_url` in your request."
69+
)
70+
6771
return func(*args, **kwargs)
6872

69-
return wrapper
73+
return wrapper

0 commit comments

Comments
 (0)