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

_qs.py — anthropic-sdk-python Source File

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

File python AnthropicClient SyncAPI 6 imports 2 dependents 2 classes

Entity Profile

Dependency Diagram

graph LR
  738dc346_a11e_4dc7_f7df_dced9f1a2476["_qs.py"]
  87f621ac_b3e0_a225_72b3_99f9818f3002["_types.py"]
  738dc346_a11e_4dc7_f7df_dced9f1a2476 --> 87f621ac_b3e0_a225_72b3_99f9818f3002
  f30eca5a_2fa0_68c1_64aa_b52331a2dcc8["NotGiven"]
  738dc346_a11e_4dc7_f7df_dced9f1a2476 --> f30eca5a_2fa0_68c1_64aa_b52331a2dcc8
  6dadb144_3070_6111_357f_214554108905["__init__.py"]
  738dc346_a11e_4dc7_f7df_dced9f1a2476 --> 6dadb144_3070_6111_357f_214554108905
  89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875["typing"]
  738dc346_a11e_4dc7_f7df_dced9f1a2476 --> 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875
  900b1f66_5ec1_5ff8_7686_a5c6e966d659["urllib.parse"]
  738dc346_a11e_4dc7_f7df_dced9f1a2476 --> 900b1f66_5ec1_5ff8_7686_a5c6e966d659
  37c05070_ca59_d596_7250_de9d1939227f["typing_extensions"]
  738dc346_a11e_4dc7_f7df_dced9f1a2476 --> 37c05070_ca59_d596_7250_de9d1939227f
  31e60ad8_cac8_652d_176d_4f7cf7dda1ad["_base_client.py"]
  31e60ad8_cac8_652d_176d_4f7cf7dda1ad --> 738dc346_a11e_4dc7_f7df_dced9f1a2476
  3a4e7de9_0222_597c_a697_7ff97bd0dafc["_client.py"]
  3a4e7de9_0222_597c_a697_7ff97bd0dafc --> 738dc346_a11e_4dc7_f7df_dced9f1a2476
  style 738dc346_a11e_4dc7_f7df_dced9f1a2476 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from __future__ import annotations

from typing import Any, List, Tuple, Union, Mapping, TypeVar
from urllib.parse import parse_qs, urlencode
from typing_extensions import Literal, get_args

from ._types import NotGiven, not_given
from ._utils import flatten

_T = TypeVar("_T")


ArrayFormat = Literal["comma", "repeat", "indices", "brackets"]
NestedFormat = Literal["dots", "brackets"]

PrimitiveData = Union[str, int, float, bool, None]
# this should be Data = Union[PrimitiveData, "List[Data]", "Tuple[Data]", "Mapping[str, Data]"]
# https://github.com/microsoft/pyright/issues/3555
Data = Union[PrimitiveData, List[Any], Tuple[Any], "Mapping[str, Any]"]
Params = Mapping[str, Data]


class Querystring:
    array_format: ArrayFormat
    nested_format: NestedFormat

    def __init__(
        self,
        *,
        array_format: ArrayFormat = "repeat",
        nested_format: NestedFormat = "brackets",
    ) -> None:
        self.array_format = array_format
        self.nested_format = nested_format

    def parse(self, query: str) -> Mapping[str, object]:
        # Note: custom format syntax is not supported yet
        return parse_qs(query)

    def stringify(
        self,
        params: Params,
        *,
        array_format: ArrayFormat | NotGiven = not_given,
        nested_format: NestedFormat | NotGiven = not_given,
    ) -> str:
        return urlencode(
            self.stringify_items(
                params,
                array_format=array_format,
                nested_format=nested_format,
            )
        )

    def stringify_items(
        self,
        params: Params,
        *,
        array_format: ArrayFormat | NotGiven = not_given,
        nested_format: NestedFormat | NotGiven = not_given,
// ... (91 more lines)

Subdomains

Dependencies

Frequently Asked Questions

What does _qs.py do?
_qs.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the AnthropicClient domain, SyncAPI subdomain.
What does _qs.py depend on?
_qs.py imports 6 module(s): NotGiven, __init__.py, _types.py, typing, typing_extensions, urllib.parse.
What files import _qs.py?
_qs.py is imported by 2 file(s): _base_client.py, _client.py.
Where is _qs.py in the architecture?
_qs.py is located at src/anthropic/_qs.py (domain: AnthropicClient, subdomain: SyncAPI, directory: src/anthropic).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free