MCPcopy Create free account
hub / github.com/anomalyco/opencode-sdk-python / to_raw_response_wrapper

Function to_raw_response_wrapper

src/opencode_ai/_response.py:737–751  ·  view source on GitHub ↗

Higher order function that takes one of our bound API methods and wraps it to support returning the raw `APIResponse` object directly.

(func: Callable[P, R])

Source from the content-addressed store, hash-verified

735
736
737def to_raw_response_wrapper(func: Callable[P, R]) -> Callable[P, APIResponse[R]]:
738 """Higher order function that takes one of our bound API methods and wraps it
739 to support returning the raw `APIResponse` object directly.
740 """
741
742 @functools.wraps(func)
743 def wrapped(*args: P.args, **kwargs: P.kwargs) -> APIResponse[R]:
744 extra_headers: dict[str, str] = {**(cast(Any, kwargs.get("extra_headers")) or {})}
745 extra_headers[RAW_RESPONSE_HEADER] = "raw"
746
747 kwargs["extra_headers"] = extra_headers
748
749 return cast(APIResponse[R], func(*args, **kwargs))
750
751 return wrapped
752
753
754def async_to_raw_response_wrapper(func: Callable[P, Awaitable[R]]) -> Callable[P, Awaitable[AsyncAPIResponse[R]]]:

Callers 7

__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected