MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / union_members

Function union_members

tests/test_open_telemetry.py:8235–8242  ·  view source on GitHub ↗

The classes of a union, a list of them, or one class, however nested or annotated.

(tp: Any)

Source from the content-addressed store, hash-verified

8233
8234
8235def union_members(tp: Any) -> list[Any]:
8236 """The classes of a union, a list of them, or one class, however nested or annotated."""
8237 origin = get_origin(tp)
8238 if origin in (Annotated, Required, NotRequired):
8239 return union_members(get_args(tp)[0])
8240 if origin in (Union, UnionType, list, Iterable, Sequence):
8241 return [member for arg in get_args(tp) for member in union_members(arg)]
8242 return [tp] if isinstance(tp, type) and (is_typeddict(tp) or issubclass(tp, pydantic.BaseModel)) else []
8243
8244
8245def field_types(cls: Any) -> dict[str, Any]:

Callers 3

type_namesFunction · 0.85
type_names_underFunction · 0.85
result_blocksFunction · 0.85

Calls 2

get_originFunction · 0.50
get_argsFunction · 0.50

Tested by

no test coverage detected