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

Method __init__

starlette/datastructures.py:256–282  ·  view source on GitHub ↗
(
        self,
        *args: ImmutableMultiDict[_KeyType, _CovariantValueType]
        | Mapping[_KeyType, _CovariantValueType]
        | Iterable[tuple[_KeyType, _CovariantValueType]],
        **kwargs: Any,
    )

Source from the content-addressed store, hash-verified

254 _dict: dict[_KeyType, _CovariantValueType]
255
256 def __init__(
257 self,
258 *args: ImmutableMultiDict[_KeyType, _CovariantValueType]
259 | Mapping[_KeyType, _CovariantValueType]
260 | Iterable[tuple[_KeyType, _CovariantValueType]],
261 **kwargs: Any,
262 ) -> None:
263 assert len(args) < 2, "Too many arguments."
264
265 value: Any = args[0] if args else []
266 if kwargs:
267 value = ImmutableMultiDict(value).multi_items() + ImmutableMultiDict(kwargs).multi_items()
268
269 if not value:
270 _items: list[tuple[Any, Any]] = []
271 elif hasattr(value, "multi_items"):
272 value = cast(ImmutableMultiDict[_KeyType, _CovariantValueType], value)
273 _items = list(value.multi_items())
274 elif hasattr(value, "items"):
275 value = cast(Mapping[_KeyType, _CovariantValueType], value)
276 _items = list(value.items())
277 else:
278 value = cast("list[tuple[Any, Any]]", value)
279 _items = list(value)
280
281 self._dict = {k: v for k, v in _items}
282 self._list = _items
283
284 def getlist(self, key: Any) -> list[_CovariantValueType]:
285 return [item_value for item_key, item_value in self._list if item_key == key]

Callers

nothing calls this directly

Calls 3

ImmutableMultiDictClass · 0.85
multi_itemsMethod · 0.80
itemsMethod · 0.45

Tested by

no test coverage detected