File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717import httpx
1818
1919from unstructured_client ._hooks .types import BeforeRequestContext , BeforeRequestHook
20+ from unstructured_client .auth ._base import _ExchangeCallableBase
2021
2122
2223class AuthHeaderBeforeRequestHook (BeforeRequestHook ):
@@ -43,11 +44,8 @@ def _is_exchange_callable(security_source: object) -> bool:
4344 token-exchange callables.
4445
4546 The SDK wraps a user-supplied callable into an internal factory and
46- attaches ``__wrapped_callable__`` to it (see ``sdk.py``). We import
47- the base class lazily to avoid any cycle at module load.
47+ attaches ``__wrapped_callable__`` to it (see ``sdk.py``).
4848 """
49- from unstructured_client .auth ._base import _ExchangeCallableBase
50-
5149 if security_source is None :
5250 return False
5351
Original file line number Diff line number Diff line change 1616
1717from __future__ import annotations
1818
19- import asyncio
2019import logging
2120import random
2221import threading
Original file line number Diff line number Diff line change 1919from __future__ import annotations
2020
2121import asyncio
22+ import concurrent .futures
2223import time
2324from typing import Any , Dict , Optional
2425
2526import httpx
2627
2728from ._base import _ExchangeCallableBase
28- from ._exceptions import InvalidCredentialError , TokenExchangeError
29+ from ._exceptions import TokenExchangeError
2930
3031
3132class ClientCredentials (_ExchangeCallableBase ):
@@ -254,14 +255,12 @@ def __call__(self) -> str:
254255 temporary loop via :func:`asyncio.run`.
255256 """
256257 try :
257- loop = asyncio .get_running_loop ()
258+ asyncio .get_running_loop ()
258259 except RuntimeError :
259260 return asyncio .run (self .acquire ())
260261
261262 # Inside a running loop - offload to a worker thread that drives its
262263 # own event loop so we don't block the caller's loop on httpx IO.
263- import concurrent .futures
264-
265264 def _run_in_new_loop () -> str :
266265 return asyncio .run (self .acquire ())
267266
You can’t perform that action at this time.
0 commit comments