_utils.py — anthropic-sdk-python Source File
Architecture documentation for _utils.py, a python file in the anthropic-sdk-python codebase. 11 imports, 3 dependents.
Entity Profile
Dependency Diagram
graph LR 875202ec_3744_577d_9ec4_ed9fbc6aaf41["_utils.py"] cde21691_6a41_9f44_bc0e_fb0aa875b99b["_types"] 875202ec_3744_577d_9ec4_ed9fbc6aaf41 --> cde21691_6a41_9f44_bc0e_fb0aa875b99b 8b7ab286_2165_44a3_b9a8_f20a2042bd76["_files"] 875202ec_3744_577d_9ec4_ed9fbc6aaf41 --> 8b7ab286_2165_44a3_b9a8_f20a2042bd76 bb0af148_44a9_df40_49c4_0fa6ceb5a403["os"] 875202ec_3744_577d_9ec4_ed9fbc6aaf41 --> bb0af148_44a9_df40_49c4_0fa6ceb5a403 cc059f4f_d2bd_7056_9086_eaeec58cbdc0["re"] 875202ec_3744_577d_9ec4_ed9fbc6aaf41 --> cc059f4f_d2bd_7056_9086_eaeec58cbdc0 506d0594_2a0d_4f14_1041_ed428dcfcac8["inspect"] 875202ec_3744_577d_9ec4_ed9fbc6aaf41 --> 506d0594_2a0d_4f14_1041_ed428dcfcac8 4c73056b_526d_2199_4a80_7fcd0cd9bcbe["functools"] 875202ec_3744_577d_9ec4_ed9fbc6aaf41 --> 4c73056b_526d_2199_4a80_7fcd0cd9bcbe 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875["typing"] 875202ec_3744_577d_9ec4_ed9fbc6aaf41 --> 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875 525f4270_cbfe_512c_fbe4_e6566e0cdf13["pathlib"] 875202ec_3744_577d_9ec4_ed9fbc6aaf41 --> 525f4270_cbfe_512c_fbe4_e6566e0cdf13 7e1d14c5_475e_409c_7c4e_1274f9d40aa9["datetime"] 875202ec_3744_577d_9ec4_ed9fbc6aaf41 --> 7e1d14c5_475e_409c_7c4e_1274f9d40aa9 37c05070_ca59_d596_7250_de9d1939227f["typing_extensions"] 875202ec_3744_577d_9ec4_ed9fbc6aaf41 --> 37c05070_ca59_d596_7250_de9d1939227f 2f182a0f_b6d1_3b84_5c3a_c9cbb0568e75["sniffio"] 875202ec_3744_577d_9ec4_ed9fbc6aaf41 --> 2f182a0f_b6d1_3b84_5c3a_c9cbb0568e75 6dadb144_3070_6111_357f_214554108905["__init__.py"] 6dadb144_3070_6111_357f_214554108905 --> 875202ec_3744_577d_9ec4_ed9fbc6aaf41 17ea9c01_2df6_304d_71e2_31af17ed7395["_transform.py"] 17ea9c01_2df6_304d_71e2_31af17ed7395 --> 875202ec_3744_577d_9ec4_ed9fbc6aaf41 b104416a_b868_41fc_902c_7e2aaf93e2af["_typing.py"] b104416a_b868_41fc_902c_7e2aaf93e2af --> 875202ec_3744_577d_9ec4_ed9fbc6aaf41 style 875202ec_3744_577d_9ec4_ed9fbc6aaf41 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from __future__ import annotations
import os
import re
import inspect
import functools
from typing import (
Any,
Tuple,
Mapping,
TypeVar,
Callable,
Iterable,
Sequence,
cast,
overload,
)
from pathlib import Path
from datetime import date, datetime
from typing_extensions import TypeGuard
import sniffio
from .._types import Omit, NotGiven, FileTypes, HeadersLike
_T = TypeVar("_T")
_TupleT = TypeVar("_TupleT", bound=Tuple[object, ...])
_MappingT = TypeVar("_MappingT", bound=Mapping[str, object])
_SequenceT = TypeVar("_SequenceT", bound=Sequence[object])
CallableT = TypeVar("CallableT", bound=Callable[..., Any])
def flatten(t: Iterable[Iterable[_T]]) -> list[_T]:
return [item for sublist in t for item in sublist]
def extract_files(
# TODO: this needs to take Dict but variance issues.....
# create protocol type ?
query: Mapping[str, object],
*,
paths: Sequence[Sequence[str]],
) -> list[tuple[str, FileTypes]]:
"""Recursively extract files from the given dictionary based on specified paths.
A path may look like this ['foo', 'files', '<array>', 'data'].
Note: this mutates the given dictionary.
"""
files: list[tuple[str, FileTypes]] = []
for path in paths:
files.extend(_extract_items(query, path, index=0, flattened_key=None))
return files
def _extract_items(
obj: object,
path: Sequence[str],
*,
index: int,
// ... (362 more lines)
Domain
Subdomains
Functions
- _extract_items()
- coerce_boolean()
- coerce_float()
- coerce_integer()
- deepcopy_minimal()
- extract_files()
- file_from_path()
- flatten()
- get_async_library()
- get_required_header()
- human_join()
- is_dict()
- is_given()
- is_iterable()
- is_list()
- is_mapping()
- is_mapping_t()
- is_sequence()
- is_sequence_t()
- is_tuple()
- is_tuple_t()
- json_safe()
- lru_cache()
- maybe_coerce_boolean()
- maybe_coerce_float()
- maybe_coerce_integer()
- quote()
- removeprefix()
- removesuffix()
- required_args()
- strip_not_given()
Dependencies
- _files
- _types
- datetime
- functools
- inspect
- os
- pathlib
- re
- sniffio
- typing
- typing_extensions
Imported By
Source
Frequently Asked Questions
What does _utils.py do?
_utils.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 _utils.py?
_utils.py defines 31 function(s): _extract_items, coerce_boolean, coerce_float, coerce_integer, deepcopy_minimal, extract_files, file_from_path, flatten, get_async_library, get_required_header, and 21 more.
What does _utils.py depend on?
_utils.py imports 11 module(s): _files, _types, datetime, functools, inspect, os, pathlib, re, and 3 more.
What files import _utils.py?
_utils.py is imported by 3 file(s): __init__.py, _transform.py, _typing.py.
Where is _utils.py in the architecture?
_utils.py is located at src/anthropic/_utils/_utils.py (domain: AnthropicClient, subdomain: AsyncAPI, directory: src/anthropic/_utils).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free