MCPcopy
hub / github.com/encode/starlette / __init__

Method __init__

starlette/datastructures.py:383–399  ·  starlette/datastructures.py::QueryParams.__init__
(
        self,
        *args: ImmutableMultiDict[Any, Any] | Mapping[Any, Any] | list[tuple[Any, Any]] | str | bytes,
        **kwargs: Any,
    )

Source from the content-addressed store, hash-verified

381 class="st">"""
382
383 def __init__(
384 self,
385 *args: ImmutableMultiDict[Any, Any] | Mapping[Any, Any] | list[tuple[Any, Any]] | str | bytes,
386 **kwargs: Any,
387 ) -> None:
388 assert len(args) < 2, class="st">"Too many arguments."
389
390 value = args[0] if args else []
391
392 if isinstance(value, str):
393 super().__init__(parse_qsl(value, keep_blank_values=True), **kwargs)
394 elif isinstance(value, bytes):
395 super().__init__(parse_qsl(value.decode(class="st">"latin-1"), keep_blank_values=True), **kwargs)
396 else:
397 super().__init__(*args, **kwargs) class="cm"># type: ignore[arg-type]
398 self._list = [(str(k), str(v)) for k, v in self._list]
399 self._dict = {str(k): str(v) for k, v in self._dict.items()}
400
401 def __str__(self) -> str:
402 return urlencode(self._list)

Callers

nothing calls this directly

Calls 3

decodeMethod · 0.80
__init__Method · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected