Iterate over a mapping that might have a list of values, yielding all key, value pairs. Almost like iter_multi_items but only allows lists, not tuples, of values so tuples can be used for files.
(data: t.Mapping[str, t.Any])
| 157 | |
| 158 | |
| 159 | def _iter_data(data: t.Mapping[str, t.Any]) -> t.Iterator[tuple[str, t.Any]]: |
| 160 | """Iterate over a mapping that might have a list of values, yielding |
| 161 | all key, value pairs. Almost like iter_multi_items but only allows |
| 162 | lists, not tuples, of values so tuples can be used for files. |
| 163 | """ |
| 164 | if isinstance(data, MultiDict): |
| 165 | yield from data.items(multi=True) |
| 166 | else: |
| 167 | for key, value in data.items(): |
| 168 | if isinstance(value, list): |
| 169 | for v in value: |
| 170 | yield key, v |
| 171 | else: |
| 172 | yield key, value |
| 173 | |
| 174 | |
| 175 | _TAnyMultiDict = t.TypeVar("_TAnyMultiDict", bound="MultiDict[t.Any, t.Any]") |
no test coverage detected