(payload: Mapping[str, object], key: str)
| 126 | |
| 127 | |
| 128 | def _require_optional_string_tuple(payload: Mapping[str, object], key: str) -> tuple[str, ...]: |
| 129 | value = payload.get(key) |
| 130 | if value is None: |
| 131 | return () |
| 132 | if not isinstance(value, Sequence) or isinstance(value, (str, bytes)): |
| 133 | raise ValueError(f"{key} must be a sequence of strings.") |
| 134 | result: list[str] = [] |
| 135 | for item in value: |
| 136 | if not isinstance(item, str): |
| 137 | raise ValueError(f"{key} must contain only strings.") |
| 138 | result.append(item) |
| 139 | return tuple(result) |
| 140 | |
| 141 | |
| 142 |
no test coverage detected