(value: Any, limit: int)
| 49 | |
| 50 | |
| 51 | def truncate(value: Any, limit: int) -> str: |
| 52 | text = json.dumps(value, ensure_ascii=False) if isinstance(value, (list, dict)) else str(value or "") |
| 53 | text = " ".join(text.split()) |
| 54 | if len(text) <= limit: |
| 55 | return text |
| 56 | return text[: max(0, limit - 3)] + "..." |
| 57 | |
| 58 | |
| 59 | def balanced_sample(rows: List[Dict[str, Any]], sample_size: int, seed: int) -> List[Dict[str, Any]]: |
no outgoing calls
no test coverage detected