Home / File/ helpers.py — anthropic-sdk-python Source File

helpers.py — anthropic-sdk-python Source File

Architecture documentation for helpers.py, a python file in the anthropic-sdk-python codebase. 3 imports, 2 dependents.

File python AnthropicClient AsyncAPI 3 imports 2 dependents 3 functions

Entity Profile

Dependency Diagram

graph LR
  31e115f3_5f92_0f4b_4468_e9937a5656c2["helpers.py"]
  bb0af148_44a9_df40_49c4_0fa6ceb5a403["os"]
  31e115f3_5f92_0f4b_4468_e9937a5656c2 --> bb0af148_44a9_df40_49c4_0fa6ceb5a403
  89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875["typing"]
  31e115f3_5f92_0f4b_4468_e9937a5656c2 --> 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875
  37c05070_ca59_d596_7250_de9d1939227f["typing_extensions"]
  31e115f3_5f92_0f4b_4468_e9937a5656c2 --> 37c05070_ca59_d596_7250_de9d1939227f
  239f7d64_6d26_d418_04e3_d586fe367986["test_beta_messages.py"]
  239f7d64_6d26_d418_04e3_d586fe367986 --> 31e115f3_5f92_0f4b_4468_e9937a5656c2
  8cc8cd20_a242_314f_b59d_2d554c624e7c["test_messages.py"]
  8cc8cd20_a242_314f_b59d_2d554c624e7c --> 31e115f3_5f92_0f4b_4468_e9937a5656c2
  style 31e115f3_5f92_0f4b_4468_e9937a5656c2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from __future__ import annotations

import os
from typing import TypeVar, Iterator
from typing_extensions import AsyncIterator

_T = TypeVar("_T")


def load_fixture(fixture_name: str) -> str:
    """Load a fixture file from the fixtures directory."""
    current_dir = os.path.dirname(os.path.abspath(__file__))
    fixtures_dir = os.path.join(current_dir, "fixtures")
    with open(os.path.join(fixtures_dir, fixture_name), "r") as f:
        return f.read()


def get_response(fixture_name: str) -> Iterator[bytes]:
    """Convert a fixture file into a stream of bytes for testing."""
    content = load_fixture(fixture_name)
    for line in content.splitlines():
        yield line.encode() + b"\n"


async def to_async_iter(iter: Iterator[_T]) -> AsyncIterator[_T]:
    """Convert a synchronous iterator to an asynchronous one."""
    for event in iter:
        yield event

Subdomains

Dependencies

  • os
  • typing
  • typing_extensions

Frequently Asked Questions

What does helpers.py do?
helpers.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 helpers.py?
helpers.py defines 3 function(s): get_response, load_fixture, to_async_iter.
What does helpers.py depend on?
helpers.py imports 3 module(s): os, typing, typing_extensions.
What files import helpers.py?
helpers.py is imported by 2 file(s): test_beta_messages.py, test_messages.py.
Where is helpers.py in the architecture?
helpers.py is located at tests/lib/streaming/helpers.py (domain: AnthropicClient, subdomain: AsyncAPI, directory: tests/lib/streaming).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free