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

_typing.py — anthropic-sdk-python Source File

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

File python AnthropicClient SyncAPI 9 imports 2 dependents 12 functions

Entity Profile

Dependency Diagram

graph LR
  b104416a_b868_41fc_902c_7e2aaf93e2af["_typing.py"]
  875202ec_3744_577d_9ec4_ed9fbc6aaf41["_utils.py"]
  b104416a_b868_41fc_902c_7e2aaf93e2af --> 875202ec_3744_577d_9ec4_ed9fbc6aaf41
  8294e4b9_a2f1_2622_baf4_5103603d0b96["lru_cache"]
  b104416a_b868_41fc_902c_7e2aaf93e2af --> 8294e4b9_a2f1_2622_baf4_5103603d0b96
  cde21691_6a41_9f44_bc0e_fb0aa875b99b["_types"]
  b104416a_b868_41fc_902c_7e2aaf93e2af --> cde21691_6a41_9f44_bc0e_fb0aa875b99b
  c96ee5ad_7068_af50_518d_eabdd7af5c4e["_compat.py"]
  b104416a_b868_41fc_902c_7e2aaf93e2af --> c96ee5ad_7068_af50_518d_eabdd7af5c4e
  1a024cc8_656e_4759_8260_2a6a9cef2ccf["is_union"]
  b104416a_b868_41fc_902c_7e2aaf93e2af --> 1a024cc8_656e_4759_8260_2a6a9cef2ccf
  42faf450_4542_3635_bb7f_62cffcc3e979["sys"]
  b104416a_b868_41fc_902c_7e2aaf93e2af --> 42faf450_4542_3635_bb7f_62cffcc3e979
  89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875["typing"]
  b104416a_b868_41fc_902c_7e2aaf93e2af --> 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875
  37c05070_ca59_d596_7250_de9d1939227f["typing_extensions"]
  b104416a_b868_41fc_902c_7e2aaf93e2af --> 37c05070_ca59_d596_7250_de9d1939227f
  d3b2e0bf_005e_95e1_6225_068afd110d49["collections"]
  b104416a_b868_41fc_902c_7e2aaf93e2af --> d3b2e0bf_005e_95e1_6225_068afd110d49
  6dadb144_3070_6111_357f_214554108905["__init__.py"]
  6dadb144_3070_6111_357f_214554108905 --> b104416a_b868_41fc_902c_7e2aaf93e2af
  17ea9c01_2df6_304d_71e2_31af17ed7395["_transform.py"]
  17ea9c01_2df6_304d_71e2_31af17ed7395 --> b104416a_b868_41fc_902c_7e2aaf93e2af
  style b104416a_b868_41fc_902c_7e2aaf93e2af fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from __future__ import annotations

import sys
import typing
import typing_extensions
from typing import Any, TypeVar, Iterable, cast
from collections import abc as _c_abc
from typing_extensions import (
    TypeIs,
    Required,
    Annotated,
    get_args,
    get_origin,
)

from ._utils import lru_cache
from .._types import InheritsGeneric
from ._compat import is_union as _is_union


def is_annotated_type(typ: type) -> bool:
    return get_origin(typ) == Annotated


def is_list_type(typ: type) -> bool:
    return (get_origin(typ) or typ) == list


def is_sequence_type(typ: type) -> bool:
    origin = get_origin(typ) or typ
    return origin == typing_extensions.Sequence or origin == typing.Sequence or origin == _c_abc.Sequence


def is_iterable_type(typ: type) -> bool:
    """If the given type is `typing.Iterable[T]`"""
    origin = get_origin(typ) or typ
    return origin == Iterable or origin == _c_abc.Iterable


def is_union_type(typ: type) -> bool:
    return _is_union(get_origin(typ))


def is_required_type(typ: type) -> bool:
    return get_origin(typ) == Required


def is_typevar(typ: type) -> bool:
    # type ignore is required because type checkers
    # think this expression will always return False
    return type(typ) == TypeVar  # type: ignore


_TYPE_ALIAS_TYPES: tuple[type[typing_extensions.TypeAliasType], ...] = (typing_extensions.TypeAliasType,)
if sys.version_info >= (3, 12):
    _TYPE_ALIAS_TYPES = (*_TYPE_ALIAS_TYPES, typing.TypeAliasType)


def is_type_alias_type(tp: Any, /) -> TypeIs[typing_extensions.TypeAliasType]:
    """Return whether the provided argument is an instance of `TypeAliasType`.
// ... (97 more lines)

Subdomains

Dependencies

Frequently Asked Questions

What does _typing.py do?
_typing.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the AnthropicClient domain, SyncAPI subdomain.
What functions are defined in _typing.py?
_typing.py defines 12 function(s): _TYPE_ALIAS_TYPES, extract_type_arg, extract_type_var_from_base, is_annotated_type, is_iterable_type, is_list_type, is_required_type, is_sequence_type, is_type_alias_type, is_typevar, and 2 more.
What does _typing.py depend on?
_typing.py imports 9 module(s): _compat.py, _types, _utils.py, collections, is_union, lru_cache, sys, typing, and 1 more.
What files import _typing.py?
_typing.py is imported by 2 file(s): __init__.py, _transform.py.
Where is _typing.py in the architecture?
_typing.py is located at src/anthropic/_utils/_typing.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