_proxy.py — anthropic-sdk-python Source File
Architecture documentation for _proxy.py, a python file in the anthropic-sdk-python codebase. 3 imports, 2 dependents.
Entity Profile
Dependency Diagram
graph LR f9a3dcc2_e2d1_7cf4_5bc6_e213b44759ac["_proxy.py"] 90b87fb1_b7c6_6103_fd94_a71d362551d6["abc"] f9a3dcc2_e2d1_7cf4_5bc6_e213b44759ac --> 90b87fb1_b7c6_6103_fd94_a71d362551d6 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875["typing"] f9a3dcc2_e2d1_7cf4_5bc6_e213b44759ac --> 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875 37c05070_ca59_d596_7250_de9d1939227f["typing_extensions"] f9a3dcc2_e2d1_7cf4_5bc6_e213b44759ac --> 37c05070_ca59_d596_7250_de9d1939227f 6dadb144_3070_6111_357f_214554108905["__init__.py"] 6dadb144_3070_6111_357f_214554108905 --> f9a3dcc2_e2d1_7cf4_5bc6_e213b44759ac 11078048_5381_375c_d4e5_8226805520d9["_resources_proxy.py"] 11078048_5381_375c_d4e5_8226805520d9 --> f9a3dcc2_e2d1_7cf4_5bc6_e213b44759ac style f9a3dcc2_e2d1_7cf4_5bc6_e213b44759ac fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import Generic, TypeVar, Iterable, cast
from typing_extensions import override
T = TypeVar("T")
class LazyProxy(Generic[T], ABC):
"""Implements data methods to pretend that an instance is another instance.
This includes forwarding attribute access and other methods.
"""
# Note: we have to special case proxies that themselves return proxies
# to support using a proxy as a catch-all for any random access, e.g. `proxy.foo.bar.baz`
def __getattr__(self, attr: str) -> object:
proxied = self.__get_proxied__()
if isinstance(proxied, LazyProxy):
return proxied # pyright: ignore
return getattr(proxied, attr)
@override
def __repr__(self) -> str:
proxied = self.__get_proxied__()
if isinstance(proxied, LazyProxy):
return proxied.__class__.__name__
return repr(self.__get_proxied__())
@override
def __str__(self) -> str:
proxied = self.__get_proxied__()
if isinstance(proxied, LazyProxy):
return proxied.__class__.__name__
return str(proxied)
@override
def __dir__(self) -> Iterable[str]:
proxied = self.__get_proxied__()
if isinstance(proxied, LazyProxy):
return []
return proxied.__dir__()
@property # type: ignore
@override
def __class__(self) -> type: # pyright: ignore
try:
proxied = self.__get_proxied__()
except Exception:
return type(self)
if issubclass(type(proxied), LazyProxy):
return type(proxied)
return proxied.__class__
def __get_proxied__(self) -> T:
return self.__load__()
def __as_proxied__(self) -> T:
"""Helper method that returns the current proxy, typed as the loaded object"""
return cast(T, self)
@abstractmethod
def __load__(self) -> T: ...
Domain
Subdomains
Classes
Dependencies
- abc
- typing
- typing_extensions
Source
Frequently Asked Questions
What does _proxy.py do?
_proxy.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the AnthropicClient domain, SyncAPI subdomain.
What does _proxy.py depend on?
_proxy.py imports 3 module(s): abc, typing, typing_extensions.
What files import _proxy.py?
_proxy.py is imported by 2 file(s): __init__.py, _resources_proxy.py.
Where is _proxy.py in the architecture?
_proxy.py is located at src/anthropic/_utils/_proxy.py (domain: AnthropicClient, subdomain: SyncAPI, directory: src/anthropic/_utils).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free