Shorten large fields before printing API payloads.
(value: Any)
| 39 | |
| 40 | |
| 41 | def _sanitize_payload(value: Any) -> Any: |
| 42 | """Shorten large fields before printing API payloads.""" |
| 43 | if isinstance(value, Mapping): |
| 44 | sanitized: dict[str, Any] = {} |
| 45 | for key, item in value.items(): |
| 46 | if key == "file_data" and isinstance(item, str): |
| 47 | sanitized[key] = item[:100] + f"... ({len(item)} chars)" |
| 48 | else: |
| 49 | sanitized[str(key)] = _sanitize_payload(item) |
| 50 | return sanitized |
| 51 | |
| 52 | if isinstance(value, Sequence) and not isinstance(value, str | bytes): |
| 53 | return [_sanitize_payload(item) for item in value] |
| 54 | |
| 55 | return value |
| 56 | |
| 57 | |
| 58 | def inspect_native_path(pdf_path: Path, provider: str, api: str | None) -> None: |
no outgoing calls
no test coverage detected