_stringify_item() — anthropic-sdk-python Function Reference
Architecture documentation for the _stringify_item() function in _qs.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD fb8d0988_171e_e6ac_7477_809943dfac39["_stringify_item()"] 765fcca3_81c1_6ab1_98e8_c2929e7562e2["Querystring"] fb8d0988_171e_e6ac_7477_809943dfac39 -->|defined in| 765fcca3_81c1_6ab1_98e8_c2929e7562e2 a4465198_32b8_125c_a12b_a1f3510b8955["stringify_items()"] a4465198_32b8_125c_a12b_a1f3510b8955 -->|calls| fb8d0988_171e_e6ac_7477_809943dfac39 ddfa0c97_1cdb_9784_5f60_3b9a93c5e730["_primitive_value_to_str()"] fb8d0988_171e_e6ac_7477_809943dfac39 -->|calls| ddfa0c97_1cdb_9784_5f60_3b9a93c5e730 style fb8d0988_171e_e6ac_7477_809943dfac39 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/anthropic/_qs.py lines 69–119
def _stringify_item(
self,
key: str,
value: Data,
opts: Options,
) -> list[tuple[str, str]]:
if isinstance(value, Mapping):
items: list[tuple[str, str]] = []
nested_format = opts.nested_format
for subkey, subvalue in value.items():
items.extend(
self._stringify_item(
# TODO: error if unknown format
f"{key}.{subkey}" if nested_format == "dots" else f"{key}[{subkey}]",
subvalue,
opts,
)
)
return items
if isinstance(value, (list, tuple)):
array_format = opts.array_format
if array_format == "comma":
return [
(
key,
",".join(self._primitive_value_to_str(item) for item in value if item is not None),
),
]
elif array_format == "repeat":
items = []
for item in value:
items.extend(self._stringify_item(key, item, opts))
return items
elif array_format == "indices":
raise NotImplementedError("The array indices format is not supported yet")
elif array_format == "brackets":
items = []
key = key + "[]"
for item in value:
items.extend(self._stringify_item(key, item, opts))
return items
else:
raise NotImplementedError(
f"Unknown array_format value: {array_format}, choose from {', '.join(get_args(ArrayFormat))}"
)
serialised = self._primitive_value_to_str(value)
if not serialised:
return []
return [(key, serialised)]
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does _stringify_item() do?
_stringify_item() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/_qs.py.
Where is _stringify_item() defined?
_stringify_item() is defined in src/anthropic/_qs.py at line 69.
What does _stringify_item() call?
_stringify_item() calls 1 function(s): _primitive_value_to_str.
What calls _stringify_item()?
_stringify_item() is called by 1 function(s): stringify_items.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free