(text: str)
| 709 | |
| 710 | |
| 711 | def _describe_shape(text: str) -> str: |
| 712 | try: |
| 713 | parsed = json.loads(text) |
| 714 | except Exception: |
| 715 | parsed = None |
| 716 | if isinstance(parsed, dict): |
| 717 | keys = ", ".join(list(parsed.keys())[:8]) |
| 718 | return f"shape=json object keys=[{keys}]" |
| 719 | if isinstance(parsed, list): |
| 720 | return f"shape=json array items={len(parsed)}" |
| 721 | lines = text.count("\n") + 1 |
| 722 | return f"shape=text lines={lines}" |
| 723 | |
| 724 | |
| 725 | def _truncate_excerpt(text: str, limit: int) -> str: |
no test coverage detected