_async_format_data() — anthropic-sdk-python Function Reference
Architecture documentation for the _async_format_data() function in _transform.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD b51a5eb9_e364_3609_4727_30f9ff170bf3["_async_format_data()"] 17ea9c01_2df6_304d_71e2_31af17ed7395["_transform.py"] b51a5eb9_e364_3609_4727_30f9ff170bf3 -->|defined in| 17ea9c01_2df6_304d_71e2_31af17ed7395 6db2b331_e127_3cb2_32c8_72a1730d0041["_async_transform_recursive()"] 6db2b331_e127_3cb2_32c8_72a1730d0041 -->|calls| b51a5eb9_e364_3609_4727_30f9ff170bf3 style b51a5eb9_e364_3609_4727_30f9ff170bf3 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/anthropic/_utils/_transform.py lines 402–426
async def _async_format_data(data: object, format_: PropertyFormat, format_template: str | None) -> object:
if isinstance(data, (date, datetime)):
if format_ == "iso8601":
return data.isoformat()
if format_ == "custom" and format_template is not None:
return data.strftime(format_template)
if format_ == "base64" and is_base64_file_input(data):
binary: str | bytes | None = None
if isinstance(data, pathlib.Path):
binary = await anyio.Path(data).read_bytes()
elif isinstance(data, io.IOBase):
binary = data.read()
if isinstance(binary, str): # type: ignore[unreachable]
binary = binary.encode()
if not isinstance(binary, bytes):
raise RuntimeError(f"Could not read bytes from {data}; Received {type(binary)}")
return base64.b64encode(binary).decode("ascii")
return data
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does _async_format_data() do?
_async_format_data() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/_utils/_transform.py.
Where is _async_format_data() defined?
_async_format_data() is defined in src/anthropic/_utils/_transform.py at line 402.
What calls _async_format_data()?
_async_format_data() is called by 1 function(s): _async_transform_recursive.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free