MCPcopy
hub / github.com/anthropics/anthropic-sdk-python / add_request_id

Function add_request_id

src/anthropic/_models.py:844–856  ·  view source on GitHub ↗
(obj: BaseModel, request_id: str | None)

Source from the content-addressed store, hash-verified

842
843
844def add_request_id(obj: BaseModel, request_id: str | None) -> None:
845 obj._request_id = request_id
846
847 # in Pydantic v1, using setattr like we do above causes the attribute
848 # to be included when serializing the model which we don't want in this
849 # case so we need to explicitly exclude it
850 if PYDANTIC_V1:
851 try:
852 exclude_fields = obj.__exclude_fields__ # type: ignore
853 except AttributeError:
854 cast(Any, obj).__exclude_fields__ = {"_request_id", "__exclude_fields__"}
855 else:
856 cast(Any, obj).__exclude_fields__ = {*(exclude_fields or {}), "_request_id", "__exclude_fields__"}
857
858
859# our use of subclassing here causes weirdness for type checkers,

Callers 3

parseMethod · 0.85
parseMethod · 0.85
parseMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected