snapshots.py — anthropic-sdk-python Source File
Architecture documentation for snapshots.py, a python file in the anthropic-sdk-python codebase. 9 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR e7250a77_f5e0_e4de_3e1b_f2b040399c23["snapshots.py"] bb0af148_44a9_df40_49c4_0fa6ceb5a403["os"] e7250a77_f5e0_e4de_3e1b_f2b040399c23 --> bb0af148_44a9_df40_49c4_0fa6ceb5a403 28b0c811_20f6_fc4a_4b48_7fb9e87bf7e5["json"] e7250a77_f5e0_e4de_3e1b_f2b040399c23 --> 28b0c811_20f6_fc4a_4b48_7fb9e87bf7e5 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875["typing"] e7250a77_f5e0_e4de_3e1b_f2b040399c23 --> 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875 37c05070_ca59_d596_7250_de9d1939227f["typing_extensions"] e7250a77_f5e0_e4de_3e1b_f2b040399c23 --> 37c05070_ca59_d596_7250_de9d1939227f 9c26e8a9_1ad2_1174_876a_1fc500ce0eaf["httpx"] e7250a77_f5e0_e4de_3e1b_f2b040399c23 --> 9c26e8a9_1ad2_1174_876a_1fc500ce0eaf f6010db4_1656_22a8_b4ae_e0060d80d8c6["respx"] e7250a77_f5e0_e4de_3e1b_f2b040399c23 --> f6010db4_1656_22a8_b4ae_e0060d80d8c6 8cc1f0ad_0f79_35fa_324c_9980bd002940["inline_snapshot"] e7250a77_f5e0_e4de_3e1b_f2b040399c23 --> 8cc1f0ad_0f79_35fa_324c_9980bd002940 d10c5377_2939_0f0b_cc44_8759393f2853["anthropic"] e7250a77_f5e0_e4de_3e1b_f2b040399c23 --> d10c5377_2939_0f0b_cc44_8759393f2853 3301081a_0f03_352d_eb3e_bf923f0d8dbc["anthropic._utils._utils"] e7250a77_f5e0_e4de_3e1b_f2b040399c23 --> 3301081a_0f03_352d_eb3e_bf923f0d8dbc style e7250a77_f5e0_e4de_3e1b_f2b040399c23 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from __future__ import annotations
import os
import json
from typing import Any, List, Callable, Awaitable, cast
from typing_extensions import TypeVar
import httpx
from respx import MockRouter
from inline_snapshot import outsource, get_snapshot_value
from anthropic import Anthropic, AsyncAnthropic
from anthropic._utils._utils import is_list
_T = TypeVar("_T")
def make_snapshot_request(
func: Callable[[Anthropic], _T],
*,
content_snapshot: Any,
respx_mock: MockRouter,
mock_client: Anthropic,
path: str,
) -> _T:
live = os.environ.get("ANTHROPIC_LIVE") == "1"
collected: list[str] = []
if live:
def _on_response(response: httpx.Response) -> None:
collected.append(json.dumps(json.loads(response.read())))
respx_mock.stop()
client = Anthropic(
http_client=httpx.Client(
event_hooks={
"response": [_on_response],
}
)
)
else:
responses = get_snapshot_value(content_snapshot)
if not is_list(responses):
responses = [responses]
curr = 0
def get_response(_request: httpx.Request) -> httpx.Response:
nonlocal curr
content = responses[curr]
assert isinstance(content, str)
curr += 1
return httpx.Response(
200,
content=content,
headers={"content-type": "application/json"},
)
// ... (200 more lines)
Domain
Subdomains
Functions
Dependencies
- anthropic
- anthropic._utils._utils
- httpx
- inline_snapshot
- json
- os
- respx
- typing
- typing_extensions
Source
Frequently Asked Questions
What does snapshots.py do?
snapshots.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the AnthropicClient domain, AsyncAPI subdomain.
What functions are defined in snapshots.py?
snapshots.py defines 4 function(s): make_async_snapshot_request, make_async_stream_snapshot_request, make_snapshot_request, make_stream_snapshot_request.
What does snapshots.py depend on?
snapshots.py imports 9 module(s): anthropic, anthropic._utils._utils, httpx, inline_snapshot, json, os, respx, typing, and 1 more.
Where is snapshots.py in the architecture?
snapshots.py is located at tests/lib/snapshots.py (domain: AnthropicClient, subdomain: AsyncAPI, directory: tests/lib).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free