MCPcopy
hub / github.com/pallets/werkzeug / __init__

Method __init__

src/werkzeug/datastructures/structures.py:181–210  ·  view source on GitHub ↗
(
        self,
        mapping: (
            MultiDict[K, V]
            | cabc.Mapping[K, V | list[V] | tuple[V, ...] | set[V]]
            | cabc.Iterable[tuple[K, V]]
            | None
        ) = None,
    )

Source from the content-addressed store, hash-verified

179 """
180
181 def __init__(
182 self,
183 mapping: (
184 MultiDict[K, V]
185 | cabc.Mapping[K, V | list[V] | tuple[V, ...] | set[V]]
186 | cabc.Iterable[tuple[K, V]]
187 | None
188 ) = None,
189 ) -> None:
190 if mapping is None:
191 super().__init__()
192 elif isinstance(mapping, MultiDict):
193 super().__init__((k, vs[:]) for k, vs in mapping.lists()) # type: ignore[misc]
194 elif isinstance(mapping, cabc.Mapping):
195 tmp = {}
196 for key, value in mapping.items():
197 if isinstance(value, (list, tuple, set)):
198 value = list(value)
199
200 if not value:
201 continue
202 else:
203 value = [value]
204 tmp[key] = value
205 super().__init__(tmp) # type: ignore[arg-type]
206 else:
207 tmp = {}
208 for key, value in mapping:
209 tmp.setdefault(key, []).append(value)
210 super().__init__(tmp) # type: ignore[arg-type]
211
212 def __getstate__(self) -> t.Any:
213 return dict(self.lists())

Callers 4

__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls 5

appendMethod · 0.80
listFunction · 0.50
listsMethod · 0.45
itemsMethod · 0.45
setdefaultMethod · 0.45

Tested by

no test coverage detected